Changeset 4894


Ignore:
Timestamp:
03/05/09 12:59:55 (11 years ago)
Author:
curtis
Message:

Tweaks to CMake configuration file, and progress on Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/native/bf-cpp/CMakeLists.txt

    r4846 r4894  
    2626project(bfjace) 
    2727 
    28 ### determine configuration ### 
     28### search for prerequisite libraries ### 
    2929 
    3030message("") 
    3131 
     32#message("-- Java Runtime:") 
    3233#find_package(Java REQUIRED) 
    33 #message("-- Java Runtime:") 
    34 #message("java             : ${JAVA_RUNTIME}") 
    35 #message("javac            : ${JAVA_COMPILE}") 
    36 #message("jar              : ${JAVA_ARCHIVE}") 
     34#message("java          : ${JAVA_RUNTIME}") 
     35#message("javac         : ${JAVA_COMPILE}") 
     36#message("jar           : ${JAVA_ARCHIVE}") 
    3737#message("") 
    3838 
     39message("-- Java Native Interface:") 
    3940find_package(JNI REQUIRED) 
    40 message("-- Java Native Interface:") 
    41 message("jawt lib         : ${JAVA_AWT_LIBRARY}") 
    42 message("jvm lib          : ${JAVA_JVM_LIBRARY}") 
    43 message("jni.h            : ${JAVA_INCLUDE_PATH}") 
    44 message("jni_md.h         : ${JAVA_INCLUDE_PATH2}") 
    45 message("jawt.h           : ${JAVA_AWT_INCLUDE_PATH}") 
     41message("jawt lib      : ${JAVA_AWT_LIBRARY}") 
     42message("jvm lib       : ${JAVA_JVM_LIBRARY}") 
     43message("jni.h         : ${JAVA_INCLUDE_PATH}") 
     44message("jni_md.h      : ${JAVA_INCLUDE_PATH2}") 
     45message("jawt.h        : ${JAVA_AWT_INCLUDE_PATH}") 
    4646message("") 
    4747 
     48# HACK - CMake on Windows refuses to find the thread library unless BOOST_ROOT 
     49#        is set, even though it can locate the Boost directory tree. 
     50#        So we first look for base Boost, then set BOOST_ROOT and look again 
     51#        for Boost Thread specifically. 
     52 
     53message("-- Boost:") 
    4854set(Boost_USE_STATIC_LIBS OFF) 
    4955set(Boost_USE_MULTITHREAD ON) 
    50 set(Boost_ADDITIONAL_VERSIONS "1.38" "1.38.0" "1.38.1" "1.39" "1.39.0" "1.39.1" 
    51   "1.40" "1.40.0" "1.40.1" "1.41" "1.41.0" "1.41.1" "1.42" "1.42.0" "1.42.1") 
     56set(Boost_ADDITIONAL_VERSIONS "1.37" "1.37.0" "1.37.1" "1.38" "1.38.0" "1.38.1" 
     57  "1.39" "1.39.0" "1.39.1" "1.40" "1.40.0" "1.40.1" "1.41" "1.41.0" "1.41.1" 
     58  "1.42" "1.42.0" "1.42.1" "1.43" "1.43.0" "1.43.1" "1.44" "1.44.0" "1.44.1") 
     59set(Boost_FIND_QUIETLY ON) 
     60find_package(Boost) 
     61if(IS_DIRECTORY "${Boost_INCLUDE_DIR}") 
     62  message("boost headers : ${Boost_INCLUDE_DIR}") 
     63else(IS_DIRECTORY "${Boost_INCLUDE_DIR}") 
     64  if(UNIX) 
     65    message(FATAL_ERROR "Cannot build without Boost Thread library. Please install libboost-thread-dev package or visit www.boost.org.") 
     66  else(UNIX) 
     67    message(FATAL_ERROR "Cannot build without Boost Thread library. Please install Boost from www.boost.org.") 
     68  endif(UNIX) 
     69endif(IS_DIRECTORY "${Boost_INCLUDE_DIR}") 
     70set(Boost_FIND_QUIETLY OFF) 
     71if(WIN32) 
     72  set(BOOST_ROOT ${Boost_INCLUDE_DIR}) 
     73endif(WIN32) 
    5274find_package(Boost COMPONENTS thread REQUIRED) 
    53 message("-- Boost:") 
    54 if(EXISTS ${Boost_LIBRARIES}) 
    55 message("boost/thread.hpp : ${Boost_INCLUDE_DIR}") 
    56 message("boost libs       : ${Boost_LIBRARIES}") 
     75 
     76# NB: Necessary on Windows to test for Boost thread when 
     77#     multiple semicolon-separated files are identified. 
     78string(REGEX REPLACE ".*;" "" Boost_THREAD_LIB_FILE "${Boost_THREAD_LIBRARY}") 
     79 
     80if(EXISTS "${Boost_THREAD_LIB_FILE}") 
     81  message("thread lib    : ${Boost_THREAD_LIBRARY}") 
     82else(EXISTS "${Boost_THREAD_LIB_FILE}") 
     83  message(FATAL_ERROR "Cannot build without Boost Thread library. Please install libboost-thread-dev package or visit www.boost.org.") 
     84endif(EXISTS "${Boost_THREAD_LIB_FILE}") 
    5785message("") 
    58 else(EXISTS ${Boost_LIBRARIES}) 
    59   message(FATAL_ERROR "Cannot build without Boost Thread library. Please install libboost-thread-dev package or visit www.boost.org.") 
    60 endif(EXISTS ${Boost_LIBRARIES}) 
    6186 
    62 if(IS_DIRECTORY ${JACE_DIR}) 
    63 else(IS_DIRECTORY ${JACE_DIR}) 
     87message("-- Jace:") 
     88if(IS_DIRECTORY "${JACE_DIR}") 
     89  message("jace root     : ${JACE_DIR}") 
     90else(IS_DIRECTORY "${JACE_DIR}") 
    6491  message(FATAL_ERROR "Cannot build without Jace. Please set JACE_DIR.") 
    65 endif(IS_DIRECTORY ${JACE_DIR}) 
     92endif(IS_DIRECTORY "${JACE_DIR}") 
    6693 
    67 include_directories(include ${JACE_DIR}/source/c++/include proxies/include 
    68   ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} ${Boost_INCLUDE_DIR}) 
     94include_directories(include "${JACE_DIR}/source/c++/include" "proxies/include" 
     95  "${JAVA_INCLUDE_PATH}" "${JAVA_INCLUDE_PATH2}" "${Boost_INCLUDE_DIR}") 
    6996 
    7097### build Jace C++ library ### 
    7198 
    72 message("-- Jace source files:") 
    73 message("jace directory   : ${JACE_DIR}") 
    74 file(GLOB_RECURSE JACE_SRC ${JACE_DIR}/source/c++/source/*.cpp) 
    75 #message("jace source      : ${JACE_SRC}") 
     99file(GLOB_RECURSE JACE_SRC "${JACE_DIR}/source/c++/source/*.cpp") 
     100#message("jace source   : ${JACE_SRC}") 
    76101message("") 
    77102 
    78103add_library(jace SHARED ${JACE_SRC}) 
    79104 
    80 target_link_libraries(jace ${JAVA_JVM_LIBRARY} ${Boost_LIBRARIES}) 
     105target_link_libraries(jace "${JAVA_JVM_LIBRARY}" "${Boost_THREAD_LIBRARY}") 
    81106 
    82 set_target_properties(jace PROPERTIES 
    83   COMPILE_FLAGS "-Wall -fpermissive") 
     107if(CMAKE_COMPILER_IS_GNUCXX) 
     108  set_target_properties(jace PROPERTIES 
     109    COMPILE_FLAGS "-fpermissive") 
     110endif(CMAKE_COMPILER_IS_GNUCXX) 
    84111 
    85 # HACK - Mac OS X 10.4 and earlier requires .jnilib extension rather than 
    86 #        .dylib when loading native code with System.loadLibrary(String). 
     112# NB: Mac OS X 10.4 and earlier requires .jnilib extension rather than 
     113#     .dylib when loading native code with System.loadLibrary(String). 
    87114if(APPLE) 
    88115  set_target_properties(jace PROPERTIES SUFFIX ".jnilib") 
     
    91118### build Bio-Formats C++ bindings ### 
    92119 
    93 message("-- Bio-Formats C++ source files:") 
    94 file(GLOB_RECURSE BFJACE_SRC proxies/source/*.cpp) 
    95 #message("  bfjace source : ${BFJACE_SRC}") 
    96 message("") 
     120#message("-- Bio-Formats C++ bindings:") 
     121file(GLOB_RECURSE BFJACE_SRC "proxies/source/*.cpp") 
     122#message("bfjace source : ${BFJACE_SRC}") 
     123#message("") 
    97124 
    98125add_library(bfjace SHARED ${BFJACE_SRC}) 
     
    100127target_link_libraries(bfjace jace) 
    101128 
    102 set_target_properties(bfjace PROPERTIES 
    103   COMPILE_FLAGS "-Wall -fpermissive") 
     129if(CMAKE_COMPILER_IS_GNUCXX) 
     130  set_target_properties(bfjace PROPERTIES 
     131    COMPILE_FLAGS "-fpermissive") 
     132endif(CMAKE_COMPILER_IS_GNUCXX) 
    104133 
    105134target_link_libraries(bfjace jace) 
     
    109138add_executable(showinf source/showinf.cpp) 
    110139 
    111 target_link_libraries(showinf bfjace jace 
    112   ${JAVA_JVM_LIBRARY}) 
     140target_link_libraries(showinf bfjace jace "${JAVA_JVM_LIBRARY}") 
    113141 
    114142### TEMP - build some examples for testing ### 
     
    116144add_executable(example1 source/example1.cpp) 
    117145 
    118 target_link_libraries(example1 bfjace jace 
    119   ${JAVA_JVM_LIBRARY}) 
     146target_link_libraries(example1 bfjace jace "${JAVA_JVM_LIBRARY}") 
    120147 
    121148add_executable(array_example source/array_example.cpp) 
    122149 
    123 target_link_libraries(array_example bfjace jace 
    124   ${JAVA_JVM_LIBRARY}) 
     150target_link_libraries(array_example bfjace jace "${JAVA_JVM_LIBRARY}") 
Note: See TracChangeset for help on using the changeset viewer.