-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCMakeLists.txt
64 lines (53 loc) · 2.61 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
cmake_minimum_required(VERSION 3.15)
project(UCDD VERSION 0.2.1 LANGUAGES CXX C)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
option(TESTING "Unit tests" OFF)
option(ASAN "Address Sanitizer" OFF)
cmake_policy(SET CMP0048 NEW) # project() command manages VERSION variables
set(CMAKE_CXX_STANDARD 17)
set(MULTI_TERMINAL 1)
CONFIGURE_FILE("src/config.h.cmake" "include/cdd/config.h")
if(CMAKE_TOOLCHAIN_FILE)
get_filename_component(TARGET ${CMAKE_TOOLCHAIN_FILE} NAME_WLE)
set(LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs-${TARGET}")
else(CMAKE_TOOLCHAIN_FILE)
set(LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs")
endif(CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using libs in ${LIBS_DIR}")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${LIBS_DIR}")
find_package(xxHash 0.8.0 REQUIRED COMPONENTS xxhash PATHS ${LIBS_DIR}/xxHash)
find_package(UUtils 1.1.1 REQUIRED PATHS ${LIBS_DIR}/UUtils)
find_package(UDBM 2.0.11 REQUIRED PATHS ${LIBS_DIR}/UDBM)
include_directories(
PRIVATE
# where the library itself will look for its internal headers
${CMAKE_BINARY_DIR}/include
PUBLIC
# where top-level project will look for the library's public headers
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
# where external projects will look for the library's public headers
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(STATIC)
# The project does not use neither threads nor networking, but
# wsock32, ws2_32 and winpthread seem to be important for self-contained static binary
set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lwsock32 -lws2_32 ${CMAKE_CXX_STANDARD_LIBRARIES}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
endif(STATIC)
if (ASAN)
add_compile_options(-fno-omit-frame-pointer -fsanitize=address)
add_link_options(-fno-omit-frame-pointer -fsanitize=address)
message(STATUS "Using Address Sanitizer")
endif(ASAN)
add_subdirectory("src")
if(TESTING)
enable_testing()
add_subdirectory("test")
endif(TESTING)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/UCDDConfigVersion.cmake VERSION ${PACKAGE_VERSION} COMPATIBILITY SameMajorVersion)
install(DIRECTORY include DESTINATION .)
install(TARGETS UCDD EXPORT UCDDConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT UCDDConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/UCDD)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/UCDDConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/UCDD )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cdd/config.h DESTINATION include/cdd/)