-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
53 lines (39 loc) · 1.57 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
cmake_minimum_required(VERSION 3.10.0)
set(DATATABLE_VERSION 0.1.0)
project(DataTable LANGUAGES C VERSION ${DATATABLE_VERSION})
set(CMAKE_C_STANDARD 99)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(DEBUG_MODE "Compile in debug mode" OFF)
option(COMPILE_TESTS "Compile tests" OFF)
option(COMPILE_STATIC "Compile as static library" ON)
if (DEBUG_MODE)
message("Compiling in debug mode...")
set(CMAKE_C_FLAGS "-O0 -g -Wall -Wextra -fsanitize=address")
else()
message("Compiling in release mode...")
set(CMAKE_C_FLAGS "-O2 -Wall")
endif()
add_subdirectory(src)
if (COMPILE_TESTS)
enable_testing()
add_subdirectory(test)
# copy test CSV data to build/test/DataTable directory
file(COPY mytable.csv DESTINATION test/DataTable)
endif()
unset(DEBUG_MODE)
unset(COMPILE_TESTS)
unset(COMPILE_STATIC)
# CONFIGURATION AND INSTALL TARGETS
# TO MAKE LIBRARY DISTRIBUTABLE
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/datatableConfig.cmake "# empty")
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/datatableConfigVersion.cmake
VERSION ${JSON_VERSION}
COMPATIBILITY SameMajorVersion)
file(GLOB DATATABLEHEADERS include/*.h)
install(TARGETS datatable DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${DATATABLEHEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/datatable)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/datatableConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/datatable)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/datatableConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/datatable)