diff --git a/CMakeLists.txt b/CMakeLists.txt index b349ffa27c485d901818dd14ba184824fca0a1a3..3cb9804b9c9f81868e163d793afcde0b7bc6b499 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ option(ENABLE_SPNAV "whether 3DConnexion devices should be supported" option(STATIC_PROPERTY_WORKAROUND "workaround for static property bug with some boost/boost_python combinations" OFF) option(DEPLOYMENT "switch on deployment settings" OFF) option(COMPILE_TESTS "wheter unit tests should be compiled by default" OFF) - +option(ENABLE_STATIC "whether static libraries should be compiled" OFF) if (CXX) set(CMAKE_CXX_COMPILER ${CXX}) endif() @@ -187,6 +187,17 @@ endif() set(CMAKE_LIBRARY_OUTPUT_DIRECTORY) set(_BOOST_MIN_VERSION 1.37) + +find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS python REQUIRED) +set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES}) +set(Boost_LIBRARIES) +find_package(Boost ${_BOOST_MIN_VERSION} + COMPONENTS unit_test_framework REQUIRED) +set(BOOST_UNIT_TEST_LIBRARIES ${Boost_LIBRARIES}) +set(Boost_LIBRARIES) +if (ENABLE_STATIC) + set(Boost_USE_STATIC_LIBS ON) +endif() find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS filesystem system REQUIRED) set(BOOST_LIBRARIES ${Boost_LIBRARIES}) @@ -194,21 +205,12 @@ set(Boost_LIBRARIES) find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS iostreams REQUIRED) set(BOOST_IOSTREAM_LIBRARIES ${Boost_LIBRARIES}) set(Boost_LIBRARIES) -find_package(Boost ${_BOOST_MIN_VERSION} - COMPONENTS unit_test_framework REQUIRED) -set(BOOST_UNIT_TEST_LIBRARIES ${Boost_LIBRARIES}) -set(Boost_LIBRARIES) -find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS python REQUIRED) -set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES}) -set(Boost_LIBRARIES) find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS program_options REQUIRED) -set(BOOST_PROGRAM_OPTIONS_LIBRARIES ${Boost_LIBRARIES}) set(Boost_LIBRARIES) find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS regex REQUIRED) set(BOOST_REGEX_LIBRARIES ${Boost_LIBRARIES}) -#find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS math REQUIRED) -#set(BOOST_MATH_LIBRARIES ${Boost_LIBRARIES}) + find_package(Qt4 4.5.0 REQUIRED) find_package(OpenGL REQUIRED) find_package(PNG REQUIRED) @@ -220,6 +222,18 @@ if (ENABLE_IMG) find_package(TIFF REQUIRED) endif() + +if (ENABLE_STATIC) + set(Boost_LIBRARIES) + set(Boost_USE_STATIC_LIBS ON) + find_package(Boost ${_BOOST_MIN_VERSION} + COMPONENTS filesystem system iostreams regex REQUIRED) + message(${Boost_LIBRARIES}) + find_package(ZLIB REQUIRED) + set(STATIC_LIBRARIES ${Boost_LIBRARIES} ${FFTW_LIBRARIES} ${TIFF_LIBRARIES} + ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) +endif() + if (ENABLE_GUI) ost_find_python_module(sip) ost_find_python_module(PyQt4) @@ -272,11 +286,5 @@ message(STATUS " Profiling support (-DPROFILE) : ${_PROFILE}\n" " Double Precision (-DUSE_DOUBLE_PRECISION) : ${_DOUBLE_PREC}\n" " Compound Lib (-DCOMPOUND_LIB) : ${_COMP_LIB}\n" - " TMAlign and TMScore (-DCOMPILE_TMTOOLS) : ${_TM_TOOLS}") - -# doc target to create HTML documentation -#set(SPHINX sphinx-build) -#set(SPHINX_OPTIONS -c doc/conf -b html -d doc/html/doctrees) -#add_custom_target(doc COMMAND -# ${SPHINX} ${SPHINX_OPTIONS} modules doc/html -# VERBATIM) + " TMAlign and TMScore (-DCOMPILE_TMTOOLS) : ${_TM_TOOLS}\n" + " Static Libraries (-DENABLE_STATIC) : ${ENABLE_STATIC}") diff --git a/cmake_support/OST.cmake b/cmake_support/OST.cmake index 9d928f6c946de5ce7a3c3f1d64991a98b2392d02..ed57c7400d716f16d804090eae93d3c9c0ae0c64 100644 --- a/cmake_support/OST.cmake +++ b/cmake_support/OST.cmake @@ -136,7 +136,7 @@ macro(module) #----------------------------------------------------------------------------- set(_ARGS "NAME;SOURCES;HEADERS;DEPENDS_ON;LINK;HEADER_OUTPUT_DIR;PREFIX") set(_ARG_PREFIX ost) - parse_argument_list(_ARG "${_ARGS}" "" ${ARGN}) + parse_argument_list(_ARG "${_ARGS}" "NO_STATIC" ${ARGN}) if (NOT _ARG_NAME) message(FATAL_ERROR "invalid use of module(): a module name must be provided") @@ -178,7 +178,7 @@ macro(module) endif() endforeach() add_library(${_LIB_NAME} SHARED ${_ABS_SOURCE_NAMES}) - + set_target_properties(${_LIB_NAME} PROPERTIES OUTPUT_NAME ${_LIB_NAME} PROJECT_LABEL ${_ARG_NAME} @@ -191,6 +191,25 @@ macro(module) LIBRARY_OUTPUT_DIRECTORY ${LIB_STAGE_PATH} ARCHIVE_OUTPUT_DIRECTORY ${LIB_STAGE_PATH} RUNTIME_OUTPUT_DIRECTORY ${LIB_STAGE_PATH}) + if (ENABLE_STATIC AND NOT _ARG_NO_STATIC) + add_library(${_LIB_NAME}_static STATIC ${_ABS_SOURCE_NAMES}) + set_target_properties(${_LIB_NAME}_static + PROPERTIES OUTPUT_NAME ${_LIB_NAME} + PROJECT_LABEL ${_ARG_NAME} + EchoString ${_ARG_NAME} + MODULE_DEPS "${_ARG_DEPENDS_ON}") + get_target_property(_DEFS ${_LIB_NAME}_static COMPILE_DEFINITIONS) + set_target_properties(${_LIB_NAME}_static PROPERTIES + COMPILE_DEFINITIONS OST_MODULE_${_UPPER_LIB_NAME}) + set_target_properties(${_LIB_NAME}_static PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${LIB_STAGE_PATH} + ARCHIVE_OUTPUT_DIRECTORY ${LIB_STAGE_PATH} + RUNTIME_OUTPUT_DIRECTORY ${LIB_STAGE_PATH}) + foreach(_DEPENDENCY ${_ARG_DEPENDS_ON}) + target_link_libraries(${_LIB_NAME}_static ost_${_DEPENDENCY}_static) + endforeach() + target_link_libraries(${_LIB_NAME} ${ZLIB_LIBRARIES}) + endif() if (APPLE) set_target_properties(${_LIB_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath,." @@ -268,20 +287,24 @@ endmacro() #------------------------------------------------------------------------------- macro(executable) parse_argument_list(_ARG - "NAME;SOURCES;LINK;DEPENDS_ON" "NO_RPATH" ${ARGN}) + "NAME;SOURCES;LINK;DEPENDS_ON" "NO_RPATH;STATIC" ${ARGN}) if (NOT _ARG_NAME) message(FATAL_ERROR "invalid use of executable(): a name must be provided") endif() add_executable(${_ARG_NAME} ${_ARG_SOURCES}) - if (APPLE AND NOT _ARG_NO_RPATH) + if (APPLE AND NOT _ARG_NO_RPATH AND NOT _ARG_STATIC) set_target_properties(${_ARG_NAME} PROPERTIES LINK_FLAGS "-Wl,-rpath,@loader_path/../lib") endif() if (_ARG_LINK) target_link_libraries(${_ARG_NAME} ${_ARG_LINK}) endif() + if (ENABLE_STATIC AND _ARG_STATIC) + set(TARGET_SUFFIX _static) + target_link_libraries(${_ARG_NAME} ${STATIC_LIBRARIES}) + endif() foreach(_DEP ${_ARG_DEPENDS_ON}) - target_link_libraries(${_ARG_NAME} ost_${_DEP}) + target_link_libraries(${_ARG_NAME} ost_${_DEP}${TARGET_SUFFIX}) endforeach() install(TARGETS ${_ARG_NAME} DESTINATION bin) endmacro() diff --git a/modules/conop/src/CMakeLists.txt b/modules/conop/src/CMakeLists.txt index 4d0840ea34d18bbe4f983c24f17d8ad8603769fd..e69c45689648a82ad4d086eb9e1657fa639d1131 100644 --- a/modules/conop/src/CMakeLists.txt +++ b/modules/conop/src/CMakeLists.txt @@ -23,7 +23,7 @@ ring_finder.cc module(NAME conop SOURCES ${OST_CONOP_SOURCES} HEADERS ${OST_CONOP_HEADERS} DEPENDS_ON mol geom db) -executable(NAME chemdict_tool SOURCES chemdict_tool.cc DEPENDS_ON io) +executable(NAME chemdict_tool SOURCES chemdict_tool.cc DEPENDS_ON io STATIC) if (COMPOUND_LIB) if (EXISTS "${COMPOUND_LIB}") diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt index 1a5104a0ae28d8670eb8887fa8c3c85f4567c1ae..9ec4e834bd6b27991a71da94ca7e61d439ccfa44 100644 --- a/modules/gui/src/CMakeLists.txt +++ b/modules/gui/src/CMakeLists.txt @@ -453,7 +453,8 @@ module(NAME gui SOURCES ${OST_GUI_MOCS} ${OST_GUI_SOURCES} ${OST_GUI_HEADERS} DEPENDS_ON gfx io mol_alg seq_alg LINK ${QT_LIBRARIES} ${PYTHON_LIBRARIES} ${BOOST_PYTHON_LIBRARIES} - ${SPNAV_LIBRARIES}) + ${SPNAV_LIBRARIES} + NO_STATIC) if (ADDITIONAL_LIBRARIES) target_link_libraries(ost_gui "${ADDITIONAL_LIBRARIES}")