mirror of
https://bitbucket.org/King_DuckZ/keepupnpup.git
synced 2024-11-07 21:29:00 +00:00
100 lines
2.8 KiB
CMake
100 lines
2.8 KiB
CMake
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
|
|
project(keepupnpup CXX)
|
|
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
|
|
|
|
set(CXX_STANDARD_REQUIRED ON)
|
|
|
|
option (USE_SYSTEM_MINIUPNP "Try to locate miniupnpc on the system and build against that" ON)
|
|
option (USE_SYSTEM_YAMLCPP "Try to locate miniupnpc on the system and build against that" ON)
|
|
|
|
include(CTest)
|
|
|
|
find_package(Boost 1.55.0 REQUIRED)
|
|
|
|
if (USE_SYSTEM_MINIUPNP)
|
|
find_package(Miniupnpc 2.0 REQUIRED)
|
|
else()
|
|
if (BUILD_SHARED_LIBS)
|
|
set(upnp_lib_type "shared")
|
|
set(UPNPC_BUILD_STATIC OFF CACHE BOOL "" FORCE)
|
|
set(UPNPC_BUILD_SHARED ON CACHE BOOL "" FORCE)
|
|
else()
|
|
set(upnp_lib_type "static")
|
|
set(UPNPC_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
|
set(UPNPC_BUILD_SHARED OFF CACHE BOOL "" FORCE)
|
|
endif()
|
|
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
|
|
add_subdirectory(lib/miniupnp/miniupnpc)
|
|
endif()
|
|
if (USE_SYSTEM_YAMLCPP)
|
|
find_package(YamlCpp 0.5.1 REQUIRED)
|
|
else()
|
|
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
|
|
add_subdirectory(lib/yaml-cpp)
|
|
endif()
|
|
|
|
add_executable(${PROJECT_NAME}
|
|
src/main.cpp
|
|
)
|
|
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_EXTENSIONS OFF)
|
|
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
|
|
add_library(${PROJECT_NAME}_implem STATIC
|
|
src/upnp.cpp
|
|
src/upnpexceptions.cpp
|
|
src/settings.cpp
|
|
)
|
|
set_property(TARGET ${PROJECT_NAME}_implem PROPERTY CXX_EXTENSIONS OFF)
|
|
set_property(TARGET ${PROJECT_NAME}_implem PROPERTY CXX_STANDARD 14)
|
|
|
|
target_include_directories(${PROJECT_NAME}_implem
|
|
PUBLIC lib/better-enums
|
|
)
|
|
target_include_directories(${PROJECT_NAME}_implem SYSTEM
|
|
PUBLIC ${Boost_INCLUDE_DIRS}
|
|
)
|
|
|
|
if (USE_SYSTEM_MINIUPNP)
|
|
target_include_directories(${PROJECT_NAME}_implem SYSTEM
|
|
PRIVATE ${MINIUPNP_INCLUDE_DIR}
|
|
)
|
|
target_link_libraries(${PROJECT_NAME}_implem
|
|
PRIVATE ${MINIUPNP_LIBRARY}
|
|
)
|
|
else()
|
|
target_include_directories(${PROJECT_NAME}_implem
|
|
PRIVATE lib/miniupnp/miniupnpc
|
|
)
|
|
target_link_libraries(${PROJECT_NAME}_implem
|
|
PRIVATE libminiupnpc-${upnp_lib_type}
|
|
)
|
|
endif()
|
|
if (USE_SYSTEM_YAMLCPP)
|
|
target_include_directories(${PROJECT_NAME}_implem SYSTEM
|
|
PRIVATE ${YAMLCPP_INCLUDE_DIR}
|
|
)
|
|
target_link_libraries(${PROJECT_NAME}_implem
|
|
PRIVATE ${YAMLCPP_LIBRARY}
|
|
)
|
|
else()
|
|
target_include_directories(${PROJECT_NAME}_implem
|
|
PRIVATE lib/yaml-cpp/include
|
|
)
|
|
target_link_libraries(${PROJECT_NAME}_implem
|
|
PRIVATE yaml-cpp
|
|
)
|
|
endif()
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
PRIVATE ${PROJECT_NAME}_implem
|
|
)
|
|
|
|
if (BUILD_TESTING)
|
|
set(BUILD_GTEST ON CACHE BOOL "" FORCE)
|
|
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
|
|
set(RC_ENABLE_GTEST ON CACHE BOOL "" FORCE)
|
|
|
|
add_subdirectory(lib/gtest)
|
|
add_subdirectory(lib/rapidcheck)
|
|
add_subdirectory(test/unit)
|
|
endif()
|