-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
81 lines (64 loc) · 3.09 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
76
77
78
79
80
81
cmake_minimum_required(VERSION 3.7)
project(SmartHouse)
# It sets default to Release build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(UNIX)
set(CMAKE_C_COMPILER /usr/bin/gcc)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
#TODO add -Werror (ofc...)
#You can specify your type of build --config Debug
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wextra -Wall -Wpedantic")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
-O -g -rdynamic -Wshadow -Wunused-parameter -Wunused-variable -Wdelete-non-virtual-dtor -Wfatal-errors \
-Woverloaded-virtual -Wunreachable-code -Wno-unused -Wundef -Wl,--no-undefined -Wl,--no-allow-shlib-undefined")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -w -Wl,--discard-all")
endif(UNIX)
SET(SMARTHOUSE_CLI SmartHouseServerCLI)
# application's directories settings
set(SMARTHOUSE_HOSTING_DIRECTORY_NAME poco_webservice)
set(SMARTHOUSE_BINARY_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)
set(SMARTHOUSE_LIBRARY_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)
set(SMARTHOUSE_CONFIG_DIRECTORY ${CMAKE_INSTALL_PREFIX}/etc/${SMARTHOUSE_HOSTING_DIRECTORY_NAME})
# Including source code of the project
set(PROJECT_INCLUDE_DIR ${CMAKE_HOME_DIRECTORY}/include)
set(PROJECT_SOURCE_DIR ${CMAKE_HOME_DIRECTORY}/src)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/build)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${CMAKE_HOME_DIRECTORY}/build)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin)
file(GLOB_RECURSE SOURCE_FILES ${PROJECT_SOURCE_DIR}/*.cpp)
include_directories(${PROJECT_INCLUDE_DIR})
include_directories(${PROJECT_SOURCE_DIR})
#Conan setup
include(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/conanbuildinfo.cmake)
conan_basic_setup()
# Handling options
option(ENABLE_TESTS
"Set to OFF|ON (default: OFF) to control build of API tests" OFF)
option(ENABLE_STANDALONE_SERVICE
"Set to OFF|ON (default: ON) to control build of API as standalone service" ON)
if (ENABLE_STANDALONE_SERVICE)
add_executable(${SMARTHOUSE_CLI} ${SOURCE_FILES})
target_include_directories(${SMARTHOUSE_CLI} PUBLIC ${PROJECT_INCLUDE_DIR})
target_link_libraries(${SMARTHOUSE_CLI} ${CONAN_LIBS})
message(STATUS "Building API with standalone service support.")
elseif ()
message(STATUS "Building without standalone service support.")
endif ()
if (ENABLE_TESTS)
add_subdirectory(tests)
message(STATUS "Building with tests")
elseif ()
message(STATUS "Building without tests")
endif ()
#### installation ###################################
# install (DIRECTORY "${CMAKE_HOME_DIRECTORY}/data/settings/"
# DESTINATION "${SMARTHOUSE_CONFIG_DIRECTORY}" FILES_MATCHING PATTERN "*.ini")
install(TARGETS ${SMARTHOUSE_CLI} DESTINATION ${SMARTHOUSE_LIBRARY_DIRECTORY})
# install(TARGETS ${SMARTHOUSE_CLI} DESTINATION ${SMARTHOUSE_BINARY_DIRECTORY} OPTIONAL)
message([Main] "Conan Libs: ${CONAN_LIBS}")
message([Main] "Project Source dir: ${PROJECT_SOURCE_DIR}")
message([Main] "Project Include dir: ${PROJECT_INCLUDE_DIR}")
message([Main] "Project Source files: ${SOURCE_FILES}")