forked from Labs64/NetLicensingClient-cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
79 lines (58 loc) · 2.5 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
cmake_minimum_required(VERSION 3.6)
project(netlicensing)
option(BUILD_SHARED_LIBS "Compile Shared Netlicensing-Client " FALSE)
set (BUILD_TESTS OFF)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(OpenSSL REQUIRED)
set(NETLICENSE_CURL_DIR "" CACHE PATH "path to custom curl distro required by Netlicensing-cpp")
if(NETLICENSE_CURL_DIR)
list(APPEND CMAKE_PREFIX_PATH "${NETLICENSE_CURL_DIR}")
endif()
find_package(CURL REQUIRED)
find_package(jsoncpp REQUIRED)
set(JSONCPP_LIBRARIES jsoncpp_lib)
if (BUILD_TESTS)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.40 REQUIRED unit_test_framework)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CURL_INCLUDE_DIRS})
include_directories(${JSONCPP_INCLUDE_DIRS})
set(LIBS ${LIBS} ${CURL_LIBRARIES} ${JSONCPP_LIBRARIES})
add_definitions(-DCURL_STATICLIB)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
endif()
# enumerate header and source files for library
file(GLOB headers include/netlicensing/*.h)
source_group(include FILES ${headers})
file(GLOB sources src/*.cc)
add_library(netlicensing ${headers} ${sources})
target_link_libraries(netlicensing ${LIBS})
target_link_libraries(netlicensing CURL::libcurl)
# Install target
#
# On Windows, redist dll libraries have to be installed in the binary directory.
if (WIN32)
install(TARGETS netlicensing ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin)
else()
install(TARGETS netlicensing DESTINATION lib)
endif()
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/netlicensing" DESTINATION include)
# demo client
file(GLOB client_demo_headers client_demo/${db2lp_component}/*h)
file(GLOB client_demo_sources client_demo/${db2lp_component}/*cc)
add_executable(netlicensing-client-demo ${client_demo_headers} ${client_demo_sources} )
target_link_libraries(netlicensing-client-demo netlicensing ${LIBS})
install(TARGETS netlicensing-client-demo DESTINATION bin)
if (BUILD_TESTS)
include_directories(${Boost_INCLUDE_DIR} )
link_directories(${Boost_LIBRARY_DIRS})
set(test_dir "${PROJECT_SOURCE_DIR}/tests")
file(GLOB_RECURSE test_headers ${test_dir}/*h)
file(GLOB_RECURSE test_sources ${test_dir}/*cc)
add_executable(run_tests ${headers} ${test_headers} ${test_sources})
set_target_properties(run_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${test_dir})
target_link_libraries(run_tests netlicensing ${LIBS})
TARGET_LINK_LIBRARIES(run_tests ${Boost_LIBRARIES})
endif()