Changeset 5154


Ignore:
Timestamp:
06/05/09 13:22:33 (11 years ago)
Author:
curtis
Message:

Add hack for CMake to recognize Boost on Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/native/itk-plugin/CMakeLists.txt

    r4953 r5154  
    5454message("") 
    5555 
     56# HACK - CMake on Windows refuses to find the thread library unless BOOST_ROOT 
     57#        is set, even though it can locate the Boost directory tree. 
     58#        So we first look for base Boost, then set BOOST_ROOT and look again 
     59#        for Boost Thread specifically. 
     60 
     61message("-- Boost:") 
    5662set(Boost_USE_STATIC_LIBS OFF) 
    5763set(Boost_USE_MULTITHREAD ON) 
    58 set(Boost_ADDITIONAL_VERSIONS "1.38" "1.38.0" "1.38.1" "1.39" "1.39.0" "1.39.1" 
    59   "1.40" "1.40.0" "1.40.1" "1.41" "1.41.0" "1.41.1" "1.42" "1.42.0" "1.42.1") 
     64set(Boost_ADDITIONAL_VERSIONS "1.37" "1.37.0" "1.37.1" "1.38" "1.38.0" "1.38.1" 
     65  "1.39" "1.39.0" "1.39.1" "1.40" "1.40.0" "1.40.1" "1.41" "1.41.0" "1.41.1" 
     66  "1.42" "1.42.0" "1.42.1" "1.43" "1.43.0" "1.43.1" "1.44" "1.44.0" "1.44.1") 
     67set(Boost_FIND_QUIETLY ON) 
     68find_package(Boost) 
     69if(IS_DIRECTORY "${Boost_INCLUDE_DIR}") 
     70  message("boost headers : ${Boost_INCLUDE_DIR}") 
     71else(IS_DIRECTORY "${Boost_INCLUDE_DIR}") 
     72  if(UNIX) 
     73    message(FATAL_ERROR "Cannot build without Boost Thread library. Please install libboost-thread-dev package or visit www.boost.org.") 
     74  else(UNIX) 
     75    message(FATAL_ERROR "Cannot build without Boost Thread library. Please install Boost from www.boost.org.") 
     76  endif(UNIX) 
     77endif(IS_DIRECTORY "${Boost_INCLUDE_DIR}") 
     78set(Boost_FIND_QUIETLY OFF) 
     79if(WIN32) 
     80  set(BOOST_ROOT ${Boost_INCLUDE_DIR}) 
     81endif(WIN32) 
    6082find_package(Boost COMPONENTS thread REQUIRED) 
    61 message("-- Boost:") 
    62 if(EXISTS ${Boost_LIBRARIES}) 
    63 message("boost/thread.hpp : ${Boost_INCLUDE_DIR}") 
    64 message("boost libs       : ${Boost_LIBRARIES}") 
     83 
     84# NB: Necessary on Windows to test for Boost Thread when 
     85#     multiple semicolon-separated files are identified. 
     86string(REGEX REPLACE ".*;" "" 
     87  Boost_THREAD_LIB_CHECK "${Boost_THREAD_LIBRARY}") 
     88string(REGEX REPLACE "/[^/]*$" "" 
     89  Boost_STRIPPED_LIB_DIR "${Boost_THREAD_LIB_CHECK}") 
     90 
     91if(EXISTS "${Boost_THREAD_LIB_CHECK}") 
     92  message("boost lib dir : ${Boost_STRIPPED_LIB_DIR}") 
     93  message("thread lib    : ${Boost_THREAD_LIBRARY}") 
     94else(EXISTS "${Boost_THREAD_LIB_CHECK}") 
     95  message(FATAL_ERROR "Cannot build without Boost Thread library. Please install libboost-thread-dev package or visit www.boost.org.") 
     96endif(EXISTS "${Boost_THREAD_LIB_CHECK}") 
    6597message("") 
    66 else(EXISTS ${Boost_LIBRARIES}) 
    67   message(FATAL_ERROR "Cannot build without Boost Thread library. Please install libboost-thread-dev package or visit www.boost.org.") 
    68 endif(EXISTS ${Boost_LIBRARIES}) 
    6998 
    7099set(JACE_DIR NOTFOUND CACHE PATH "The path to toplevel directory of your Jace checkout") 
    71100if(NOT JACE_DIR) 
    72  message(FATAL_ERROR "Please set JACE_DIR to the toplevel directory of your Jace checkout") 
     101  message(FATAL_ERROR "Please set JACE_DIR to the toplevel directory of your Jace checkout") 
    73102endif() 
    74103 
     
    76105 
    77106set(include_dirs 
    78  ${CMAKE_CURRENT_SOURCE_DIR} 
    79  ${CMAKE_CURRENT_BINARY_DIR} 
    80  ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} ${Boost_INCLUDE_DIR} 
    81  ${JACE_DIR}/source/c++/include 
    82  ${BF_JACE_DIR}/include 
    83  ${BF_JACE_DIR}/proxies/include 
    84  ) 
     107  ${CMAKE_CURRENT_SOURCE_DIR} 
     108  ${CMAKE_CURRENT_BINARY_DIR} 
     109  ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} ${Boost_INCLUDE_DIR} 
     110  ${JACE_DIR}/source/c++/include 
     111  ${BF_JACE_DIR}/include 
     112  ${BF_JACE_DIR}/proxies/include 
     113) 
    85114 
    86115#if(EXISTS "${ITK_DIR}/CMakeCache.txt") 
     
    94123 
    95124configure_file( 
    96  ${CMAKE_CURRENT_SOURCE_DIR}/itkBioFormatsImageIOConfigure.h.in 
    97  ${CMAKE_CURRENT_BINARY_DIR}/itkBioFormatsImageIOConfigure.h 
    98  ) 
     125  ${CMAKE_CURRENT_SOURCE_DIR}/itkBioFormatsImageIOConfigure.h.in 
     126  ${CMAKE_CURRENT_BINARY_DIR}/itkBioFormatsImageIOConfigure.h 
     127) 
    99128 
    100129file(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") 
    101130install(FILES 
    102  ${headers} 
    103  "${CMAKE_CURRENT_BINARY_DIR}/itkBioFormatsImageIOConfigure.h" 
    104  DESTINATION include/${PROJECT_NAME} COMPONENT Development 
    105  ) 
     131  ${headers} 
     132  "${CMAKE_CURRENT_BINARY_DIR}/itkBioFormatsImageIOConfigure.h" 
     133  DESTINATION include/${PROJECT_NAME} COMPONENT Development 
     134) 
    106135 
    107136# -------------------------------------------------------------------------- 
     
    109138 
    110139set(BioFormatsImageIO_SRCS 
    111  itkBioFormatsImageIO.cxx 
    112  itkBioFormatsImageIOFactory.cxx 
    113  ) 
     140  itkBioFormatsImageIO.cxx 
     141  itkBioFormatsImageIOFactory.cxx 
     142) 
    114143 
    115144# -------------------------------------------------------------------------- 
     
    118147set(lib_name BioFormatsIO) 
    119148add_library(${lib_name} 
    120  ${BioFormatsImageIO_SRCS} 
    121  ) 
     149  ${BioFormatsImageIO_SRCS} 
     150) 
    122151 
    123152target_link_libraries(${lib_name} 
    124  ITKIO 
    125  jace 
    126  bfjace 
    127  ${JAVA_JVM_LIBRARY} ${Boost_LIBRARIES} 
     153  ITKIO 
     154  jace 
     155  bfjace 
     156  ${JAVA_JVM_LIBRARY} ${Boost_LIBRARIES} 
    128157) 
    129158 
    130159install(TARGETS ${lib_name} 
    131  RUNTIME DESTINATION bin COMPONENT RuntimeLibraries 
    132  LIBRARY DESTINATION lib/${PROJECT_NAME} COMPONENT RuntimeLibraries 
    133  ARCHIVE DESTINATION lib/${PROJECT_NAME} COMPONENT Development 
     160  RUNTIME DESTINATION bin COMPONENT RuntimeLibraries 
     161  LIBRARY DESTINATION lib/${PROJECT_NAME} COMPONENT RuntimeLibraries 
     162  ARCHIVE DESTINATION lib/${PROJECT_NAME} COMPONENT Development 
    134163) 
    135164 
     
    141170 
    142171if(NOT DEFINED BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR) 
    143  set(BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR lib/ITKFactories) 
     172  set(BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR lib/ITKFactories) 
    144173endif(NOT DEFINED BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR) 
    145174 
    146175add_library(BioFormatsIOPlugin SHARED 
    147  itkBioFormatsIOPlugin.cxx 
    148  ) 
     176  itkBioFormatsIOPlugin.cxx 
     177) 
    149178set_target_properties(BioFormatsIOPlugin 
    150  PROPERTIES 
    151  RUNTIME_OUTPUT_DIRECTORY 
    152  "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}" 
    153  LIBRARY_OUTPUT_DIRECTORY 
    154  "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}" 
    155  ARCHIVE_OUTPUT_DIRECTORY 
    156  "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}" 
    157  ) 
     179  PROPERTIES 
     180  RUNTIME_OUTPUT_DIRECTORY 
     181  "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}" 
     182  LIBRARY_OUTPUT_DIRECTORY 
     183  "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}" 
     184  ARCHIVE_OUTPUT_DIRECTORY 
     185  "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}" 
     186) 
    158187target_link_libraries(BioFormatsIOPlugin 
    159  ${lib_name} 
    160  jace 
    161  bfjace 
    162  ${JAVA_JVM_LIBRARY} ${Boost_LIBRARIES} 
     188  ${lib_name} 
     189  jace 
     190  bfjace 
     191  ${JAVA_JVM_LIBRARY} ${Boost_LIBRARIES} 
    163192) 
    164193 
    165194install(TARGETS BioFormatsIOPlugin 
    166  RUNTIME DESTINATION ${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR} COMPONENT RuntimeLibraries 
    167  LIBRARY DESTINATION ${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR} COMPONENT RuntimeLibraries 
    168  ARCHIVE DESTINATION lib/${PROJECT_NAME} COMPONENT Development 
    169  ) 
     195  RUNTIME DESTINATION ${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR} COMPONENT RuntimeLibraries 
     196  LIBRARY DESTINATION ${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR} COMPONENT RuntimeLibraries 
     197  ARCHIVE DESTINATION lib/${PROJECT_NAME} COMPONENT Development 
     198) 
    170199 
    171200# make a copy named '.so' for compatibility with the expectations 
     
    173202 
    174203if(APPLE) 
    175  add_custom_command( 
    176    TARGET BioFormatsIOPlugin 
    177    DEPENDS "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}/libBioFormatsIOPlugin.dylib" 
    178    POST_BUILD 
    179    COMMAND ${CMAKE_COMMAND} -E copy 
    180    "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}/libBioFormatsIOPlugin.dylib" 
    181    "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}/libBioFormatsIOPlugin.so" 
    182    VERBATIM 
    183    ) 
    184  install(FILES 
    185    "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}/libBioFormatsIOPlugin.so" 
    186    DESTINATION ${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR} 
    187    ) 
     204  add_custom_command( 
     205    TARGET BioFormatsIOPlugin 
     206    DEPENDS "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}/libBioFormatsIOPlugin.dylib" 
     207    POST_BUILD 
     208    COMMAND ${CMAKE_COMMAND} -E copy 
     209    "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}/libBioFormatsIOPlugin.dylib" 
     210    "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}/libBioFormatsIOPlugin.so" 
     211    VERBATIM 
     212  ) 
     213  install(FILES 
     214    "${CMAKE_BINARY_DIR}/${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR}/libBioFormatsIOPlugin.so" 
     215    DESTINATION ${BioFormatsImageIO_INSTALL_ITKFACTORIES_DIR} 
     216  ) 
    188217endif(APPLE) 
Note: See TracChangeset for help on using the changeset viewer.