Changeset 7733


Ignore:
Timestamp:
08/16/11 15:22:09 (8 years ago)
Author:
hinerm
Message:

Updated CMakeLists for OSX + Linux

Changes include:
*Removed redundant include of /jace, putting every library at the top level
*Linux-specific code to embed the current working directory in each object's rpath
*Linux-specific code to install objects as FILES (instead of TARGETS as on OSX)

Known bug: installing as TARGETS on Linux caused links to system libraries to be lost upon packaging

Location:
trunk/projects/jar2lib/src/main/resources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/jar2lib/src/main/resources/CMakeLists.vm

    r7731 r7733  
    99project($projectId) 
    1010 
    11 include(jace/Prerequisites.cmake) 
    12  
    13 add_subdirectory(jace) 
    14  
    15 include_directories(include "proxies/include" "jace/include" "jtools/include" 
    16   "${JAVA_INCLUDE_PATH}" "${JAVA_INCLUDE_PATH2}" "${Boost_INCLUDE_DIR}") 
    17  
    18 file(GLOB_RECURSE PROJECT_SRC "proxies/source/*.cpp") 
    19  
    20 add_library(jtools SHARED "jtools/source/javaTools.cxx") 
     11include(jace/CMakeLists.txt) 
     12 
     13include_directories("${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/proxies/include" "${PROJECT_SOURCE_DIR}/jace/include" "${PROJECT_SOURCE_DIR}/jtools/include" "${JAVA_INCLUDE_PATH}" "${JAVA_INCLUDE_PATH2}" "${Boost_INCLUDE_DIR}") 
     14 
     15file(GLOB_RECURSE PROJECT_SRC "${PROJECT_SOURCE_DIR}/proxies/source/*.cpp") 
     16 
     17add_library(jtools SHARED "${PROJECT_SOURCE_DIR}/jtools/source/javaTools.cxx") 
    2118 
    2219add_library($projectId SHARED ${PROJECT_SRC}) 
     
    4138#end##foreach $sourceFile 
    4239 
    43 ### post-build copies to dist dir ### 
     40# ---HACK--- Force linker to check working directory for libraries on Unix 
     41if(UNIX) 
     42target_link_libraries(jtools -Wl,-rpath,.) 
     43target_link_libraries($projectId -Wl,-rpath,.) 
     44#foreach ($sourceFile in $sourceFiles) 
     45#set ($execName = $q.simpleName($sourceFile)) 
     46target_link_libraries($execName -Wl,-rpath,.) 
     47#end##foreach $sourceFile 
     48endif(UNIX) 
     49 
     50# post-build copies to dist dir 
    4451if(NOT DEFINED Jar2Lib_JACE_DIR) 
    45   set(Jar2Lib_JACE_DIR jace) 
     52# set(Jar2Lib_JACE_DIR jace) 
    4653endif(NOT DEFINED Jar2Lib_JACE_DIR) 
    4754 
     
    7481endif(NOT DEFINED J2L_LIB_PREFIX) 
    7582 
     83# Set the appropriate file extension for libraries on each system 
    7684if(APPLE) 
    7785 
     
    184192endif(APPLE) 
    185193 
    186 #copy jace 
     194# copy jace 
    187195add_custom_command( 
    188196  TARGET ${projectId} 
     
    199207) 
    200208 
    201 #copy ${projectId} 
     209# copy ${projectId} 
    202210add_custom_command( 
    203211  TARGET ${projectId} 
     
    210218) 
    211219 
    212 #copy jtools 
     220# copy jtools 
    213221add_custom_command( 
    214222  TARGET jtools 
     
    284292  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}/" 
    285293  DESTINATION "./${Jar2Lib_DEPS_DIR}/" 
     294) 
     295 
     296# copy dependencies to build directory 
     297add_custom_command( 
     298  TARGET ${projectId} 
     299  DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}" 
     300  POST_BUILD 
     301  COMMAND ${CMAKE_COMMAND} -E copy_directory 
     302  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}/" 
     303  "${CMAKE_BINARY_DIR}/${Jar2Lib_DEPS_DIR}" 
     304  VERBATIM 
    286305) 
    287306 
     
    312331) 
    313332 
     333# ---HACK--- install(TARGETS ...) destroys linking on Linux but allows portability on OSX 
     334if(UNIX) 
     335install(FILES 
     336  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}" 
     337  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}${projectId}${J2L_SUFFIX}" 
     338  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}" 
     339  DESTINATION "." 
     340) 
     341 
     342#foreach ($sourceFile in $sourceFiles) 
     343#set ($execName = $q.simpleName($sourceFile)) 
     344install(PROGRAMS 
     345  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${execName}" 
     346  DESTINATION "." 
     347) 
     348#end##foreach $sourceFile 
     349endif(UNIX) 
     350 
     351if(APPLE) 
    314352# install targets 
    315353install(TARGETS 
     
    324362  ARCHIVE DESTINATION . 
    325363) 
     364endif(APPLE) 
     365 
     366if(WIN32) 
     367# install targets 
     368install(TARGETS 
     369  jtools 
     370  ${projectId} 
     371#foreach ($sourceFile in $sourceFiles) 
     372#set ($execName = $q.simpleName($sourceFile)) 
     373  ${execName} 
     374#end##foreach $sourceFile 
     375  RUNTIME DESTINATION . 
     376  LIBRARY DESTINATION . 
     377  ARCHIVE DESTINATION . 
     378) 
     379endif(WIN32) 
    326380 
    327381SET(CPACK_PACKAGE_FILE_NAME "${projectId}") 
  • trunk/projects/jar2lib/src/main/resources/project-files/jace/CMakeLists.txt

    r6811 r7733  
    99project(jace) 
    1010 
    11 include(Prerequisites.cmake) 
     11include(jace/Prerequisites.cmake) 
    1212 
    1313### build Jace C++ library ### 
     
    1717  "${Boost_INCLUDE_DIR}") 
    1818 
    19 file(GLOB_RECURSE JACE_SRC "source/*.cpp") 
     19file(GLOB_RECURSE JACE_SRC "jace/source/*.cpp") 
    2020 
    2121add_library(jace SHARED ${JACE_SRC}) 
Note: See TracChangeset for help on using the changeset viewer.