forked from amiremohamadi/DuckX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (58 loc) · 2.38 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
cmake_minimum_required(VERSION 3.13) # for CMP0077
project(duckx VERSION 0.2)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()
option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
option(BUILD_SAMPLES "Build provided samples" OFF)
option(DUCKX_INSTALL "Install DuckX" ON)
# Fix issues when building with clang 12, next version of clang
# else we might encounter errors making the library
# not being able to be compiled
set(CMAKE_CXX_STANDARD 11)
set(HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/duckx/duckx.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/duckx/constants.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/include/duckx/duckxiterator.hpp")
set(SOURCES src/duckx.cpp)
set(THIRD_PARTY_SRC "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zip/zip.c")
if(BUILD_SHARED_LIBS)
add_library(duckx SHARED ${SOURCES} ${THIRD_PARTY_SRC})
else()
add_library(duckx STATIC ${SOURCES} ${THIRD_PARTY_SRC})
endif()
add_library(duckx::duckx ALIAS duckx)
target_include_directories(duckx PRIVATE src include/duckx)
target_include_directories(duckx PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/pugixml>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zip>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
mark_as_advanced(CLEAR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR)
if (BUILD_SAMPLES)
# Sample executable
set(SAMPLE1_SOURCES samples/sample1.cpp)
add_executable(duckx_sample1 ${SAMPLE1_SOURCES})
target_link_libraries(duckx_sample1 duckx)
set(SAMPLE2_SOURCES samples/sample2.cpp)
add_executable(duckx_sample2 ${SAMPLE2_SOURCES})
target_link_libraries(duckx_sample2 duckx)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/samples/my_test.docx
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
if (DUCKX_INSTALL)
include(GNUInstallDirs)
install(
TARGETS duckx
EXPORT duckxConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${INSTALL_SUFFIX}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${INSTALL_SUFFIX}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(EXPORT duckxConfig NAMESPACE duckx:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/duckx)
install(FILES ${HEADERS} DESTINATION include)
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()