Skip to content

Commit f94167d

Browse files
Tweaking cmake (#109)
1 parent a50e6d3 commit f94167d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
cmake_minimum_required(VERSION 3.0)
22

3+
# Acquire countly version from constant
34
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/include/countly/constants.hpp COUNTLY_HPP_CONTENTS)
45
string(REGEX MATCH "#define COUNTLY_SDK_VERSION \"[^\"]+\"" COUNTLY_SDK_VERSION ${COUNTLY_HPP_CONTENTS})
56
string(REGEX REPLACE "#define COUNTLY_SDK_VERSION \"([^\"]+)\"" "\\1" COUNTLY_SDK_VERSION ${COUNTLY_SDK_VERSION})
67

78
project(countly VERSION ${COUNTLY_SDK_VERSION} LANGUAGES CXX)
89

10+
# setup configuration options and their default values
911
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
1012
option(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "Create a module definition (.def) on Windows." ON)
1113
option(COUNTLY_USE_CUSTOM_HTTP "Use a custom HTTP library" OFF)
@@ -26,14 +28,17 @@ if (NOT WIN32 AND NOT BUILD_SHARED_LIBS AND NOT COUNTLY_USE_CUSTOM_HTTP)
2628
message(FATAL_ERROR "You must provide a custom HTTP function when compiling statically.")
2729
endif()
2830

31+
# Compile countly public headers
2932
set(COUNTLY_PUBLIC_HEADERS
3033
${CMAKE_CURRENT_SOURCE_DIR}/include/countly.hpp
3134
${CMAKE_CURRENT_SOURCE_DIR}/include/countly/constants.hpp
3235
${CMAKE_CURRENT_SOURCE_DIR}/include/countly/event.hpp
36+
3337
${CMAKE_CURRENT_SOURCE_DIR}/include/countly/logger_module.hpp
3438
${CMAKE_CURRENT_SOURCE_DIR}/include/countly/crash_module.hpp
3539
${CMAKE_CURRENT_SOURCE_DIR}/include/countly/request_module.hpp
3640
${CMAKE_CURRENT_SOURCE_DIR}/include/countly/request_builder.hpp
41+
${CMAKE_CURRENT_SOURCE_DIR}/include/countly/storage_module.hpp
3742
${CMAKE_CURRENT_SOURCE_DIR}/include/countly/views_module.hpp)
3843

3944
add_library(countly
@@ -44,6 +49,7 @@ add_library(countly
4449
${CMAKE_CURRENT_SOURCE_DIR}/src/request_module.cpp
4550
${CMAKE_CURRENT_SOURCE_DIR}/src/crash_module.cpp
4651
${CMAKE_CURRENT_SOURCE_DIR}/src/request_builder.cpp
52+
${CMAKE_CURRENT_SOURCE_DIR}/src/storage_module.cpp
4753
${CMAKE_CURRENT_SOURCE_DIR}/src/event.cpp)
4854

4955
target_include_directories(countly
@@ -129,8 +135,13 @@ endif()
129135
if(COUNTLY_BUILD_SAMPLE)
130136
message("Building sample directories")
131137
add_executable(countly-sample
132-
${CMAKE_CURRENT_SOURCE_DIR}/examples/example_integration.cpp)
133-
138+
${CMAKE_CURRENT_SOURCE_DIR}/examples/example_integration.cpp)
139+
140+
if(COUNTLY_USE_SQLITE)
141+
message("Compiling definitions for sqlite")
142+
target_compile_definitions(countly-sample PRIVATE COUNTLY_USE_SQLITE)
143+
target_include_directories(countly-sample PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/sqlite)
144+
endif()
134145
target_include_directories(countly-sample PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/doctest/doctest)
135146
target_include_directories(countly-sample PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/vendor/json/include)
136147
target_link_libraries(countly-sample countly)
@@ -140,4 +151,4 @@ if(COUNTLY_BUILD_SAMPLE)
140151
CXX_EXTENSIONS NO)
141152
endif()
142153

143-
install(TARGETS countly ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include/countly)
154+
install(TARGETS countly ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include/countly)

0 commit comments

Comments
 (0)