-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
66 lines (55 loc) · 2.31 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
cmake_minimum_required(VERSION 3.9)
# Without C++11, compile error
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_FLAGS "-O2")
# cmake config
project(DataTable VERSION 1.0.0 DESCRIPTION "Data Tables for C++")
include(GNUInstallDirs)
## create shared library (.so file) which is the source code for the project
add_library(DataTable SHARED
src/DataTable/DataTable.cc
src/DataTable/StringUtils.cc
src/DataTable/DateUtils.cc
)
## create list of includes (public headers)
## THese will be included in the programs using our program
set(PHEADERS
"include/DataTable/DataTable.hpp"
"include/DataTable/StringUtils.hpp"
"include/DataTable/DateUtils.hpp"
"include/DataTable/DataTableException.hpp"
"include/DataTable/ShapeType.hpp"
"include/DataTable/ColumnNames.hpp"
)
# some CMAKE config
# PHEADERS and PUBLIC_HEADER allow us to include the headers in our project,
# i.e. they create the /usr/local/YALL/*.hpp files
set_target_properties(DataTable PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER "${PHEADERS}")
## Create the pkg-config file
configure_file(datatable.pc.in datatable.pc @ONLY)
## not 100% sure here
## A good way to thinkg of this is that we're adding the second part (after the PRIVATE/PUBLIC/etc.)
## as compiler flags in the Makefile with the first value as the target (YALL) which are just Makefile
## targets.
target_include_directories(DataTable PRIVATE include)
target_include_directories(DataTable PRIVATE src)
## e.g. add the flag -Wno-psabi to the Makefile target YALL
target_compile_options(DataTable PRIVATE -Wno-psabi)
## Install the project shared library files and the PUBLIC HEADERS (files to be used by apps:).
install(TARGETS DataTable
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/DataTable
)
## builc the .pc pkg-config file and move it
install(FILES ${CMAKE_BINARY_DIR}/datatable.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
## Need to copy these files to the include directories to be includeed by the public headers.
install(DIRECTORY "include/DataTable/" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/DataTable)
## need to find a better way
# enable_testing()
# add_test(DataSelectionTest "${PROJECT_SOURCE_DIR}/test/DataSelectionTest")
# add_test(FileReadTest "${PROJECT_SOURCE_DIR}/test/FileReadTest")