Skip to content

Commit

Permalink
Merge pull request #12 from RasmusRendal/master
Browse files Browse the repository at this point in the history
Add support for using system version of libraries
  • Loading branch information
petergjoel authored Oct 27, 2020
2 parents 8e16717 + fe6893f commit 4ad7168
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@ set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)
option(STRATEGY_GetDependencies "Fetch external dependencies from web." ON)

if (STRATEGY_GetDependencies)
ExternalProject_add(ptrie-ext
ExternalProject_add(ptrie
URL https://github.com/petergjoel/ptrie/archive/v1.1.1.zip
URL_HASH SHA512=5435D6F8132D273B50ECCD721790D559F7DC67FFDADA75FEC315F4C53705199F31F1DDC80DDA0CB86F883DB27076FA6D324D28516B442FECCE3FFA51213AEF4E
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release
)

ExternalProject_add(json-ext
ExternalProject_add(nlohmann_json
URL https://github.com/nlohmann/json/archive/v3.7.3.zip
URL_HASH SHA512=b47a07de9a071cce645a173d084df5dd31f7669154fc00f6c99e0506474d30e8376acaee1d3c79a50def4f25a36042951bfa4fca9a704687e59c368d05053158
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DJSON_BuildTests=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
)

include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
else (STRATEGY_GetDependencies)
find_package(nlohmann_json 3.7.3 REQUIRED)
find_package(ptrie 1.1.1 REQUIRED)
endif (STRATEGY_GetDependencies)

# Unset Boost_ROOT here if set, not needed for JSON or source of strategy
Expand Down
12 changes: 9 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ if(NOT LIBSTRATEGY_OnlyLibrary)
endif()

add_library(strategy SHARED ${HEADER_FILES} libz2s.cpp ZonotopStrategy.cpp SimpleTree.cpp)
add_dependencies(strategy ptrie-ext json-ext)
if (STRATEGY_GetDependencies)
add_dependencies(strategy ptrie json)
endif (STRATEGY_GetDependencies)
target_include_directories (strategy PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

add_library(strategyStatic STATIC ${HEADER_FILES} libz2s.cpp ZonotopStrategy.cpp SimpleTree.cpp)
add_dependencies(strategyStatic ptrie-ext json-ext)
if (STRATEGY_GetDependencies)
add_dependencies(strategyStatic ptrie json)
endif (STRATEGY_GetDependencies)
target_include_directories (strategyStatic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(strategyStatic PROPERTIES OUTPUT_NAME strategy)

if(NOT LIBSTRATEGY_OnlyLibrary)
add_executable(z2s ${HEADER_FILES} main.cpp ZonotopStrategy.cpp SimpleTree.cpp)
add_dependencies(z2s ptrie-ext json-ext)
if (STRATEGY_GetDependencies)
add_dependencies(z2s ptrie json)
endif (STRATEGY_GetDependencies)
target_link_libraries(z2s PRIVATE stdc++fs ${Boost_LIBRARIES})
endif()

Expand Down

0 comments on commit 4ad7168

Please sign in to comment.