diff --git a/CMakeLists.txt b/CMakeLists.txt index 23bd9f22a..3b9669e61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,29 +271,33 @@ if (KAHYPAR_ENABLE_TESTING) endif() -if(NOT BUILD_SHARED_LIBS AND KAHYPAR_STATIC_LINK_DEPENDENCIES) - set(Boost_USE_STATIC_LIBS ON) -endif() if(NOT KAHYPAR_DISABLE_BOOST) - if(KAHYPAR_DOWNLOAD_BOOST) - # Download Boost program options - set(BOOST_INCLUDE_LIBRARIES program_options) - set(BOOST_ENABLE_CMAKE ON) - FetchContent_Declare( - Boost EXCLUDE_FROM_ALL SYSTEM - URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz - ) - FetchContent_MakeAvailable(Boost) - else() - # Find Boost program options system library - find_package(Boost 1.69 REQUIRED COMPONENTS program_options) - if(NOT Boost_FOUND) - message(FATAL_ERROR " - Boost not found. Install Boost on your system or - add -DKAHYPAR_DOWNLOAD_BOOST=On to the cmake build command.") + block() + if(KAHYPAR_STATIC_LINK_DEPENDENCIES AND (NOT BUILD_SHARED_LIBS OR KAHYPAR_DOWNLOAD_BOOST)) + set(Boost_USE_STATIC_LIBS ON) + set(BUILD_SHARED_LIBS OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() - message(STATUS "Boost Include: ${Boost_INCLUDE_DIRS}, Boost Library: ${Boost_LIBRARY_DIRS}") - endif() + if(KAHYPAR_DOWNLOAD_BOOST) + # Download Boost program options + set(BOOST_INCLUDE_LIBRARIES program_options) + set(BOOST_ENABLE_CMAKE ON) + FetchContent_Declare( + Boost EXCLUDE_FROM_ALL SYSTEM + URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.gz + ) + FetchContent_MakeAvailable(Boost) + else() + # Find Boost program options system library + find_package(Boost 1.69 REQUIRED COMPONENTS program_options) + if(NOT Boost_FOUND) + message(FATAL_ERROR " + Boost not found. Install Boost on your system or + add -DKAHYPAR_DOWNLOAD_BOOST=On to the cmake build command.") + endif() + message(STATUS "Boost Include: ${Boost_INCLUDE_DIRS}, Boost Library: ${Boost_LIBRARY_DIRS}") + endif() + endblock() target_link_libraries(MtKaHyPar-Include INTERFACE Boost::program_options) endif() @@ -307,7 +311,10 @@ if(KAHYPAR_DOWNLOAD_TBB) GIT_SHALLOW FALSE # TBB seems to assume that a git repo is present ) block() - if(NOT KAHYPAR_STATIC_LINK_TBB) + if(KAHYPAR_STATIC_LINK_TBB) + set(BUILD_SHARED_LIBS OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + else() set(BUILD_SHARED_LIBS ON) endif() FetchContent_MakeAvailable(TBB)