This repository has been archived by the owner on Jan 17, 2020. It is now read-only.
/
CMakeLists.txt
74 lines (58 loc) · 2.25 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
cmake_minimum_required(VERSION 2.4.0)
# Set the plugin name to build
project(HttpNorthC)
# Supported options:
# -DFOGLAMP_INCLUDE
# -DFOGLAMP_LIB
# -DFOGLAMP_SRC
# -DFOGLAMP_INSTALL
#
# If no -D options are given and FOGLAMP_ROOT environment variable is set
# then FogLAMP libraries and header files are pulled from FOGLAMP_ROOT path.
set(CMAKE_CXX_FLAGS "-std=c++11 -O0")
# Set plugin type (south, north, filter)
set(PLUGIN_TYPE "north")
# Add here all needed FogLAMP libraries as list
set(NEEDED_FOGLAMP_LIBS common-lib plugins-common-lib)
# Find source files
file(GLOB SOURCES *.cpp)
# Find FogLAMP includes and libs, by including FindFogLAMP.cmak file
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
find_package(FogLAMP)
# If errors: make clean and remove Makefile
if (NOT FOGLAMP_FOUND)
if (EXISTS "${CMAKE_BINARY_DIR}/Makefile")
execute_process(COMMAND make clean WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
file(REMOVE "${CMAKE_BINARY_DIR}/Makefile")
endif()
# Stop the build process
message(FATAL_ERROR "FogLAMP plugin '${PROJECT_NAME}' build error.")
endif()
# On success, FOGLAMP_INCLUDE_DIRS and FOGLAMP_LIB_DIRS variables are set
# Add ./include
include_directories(include)
# Add FogLAMP include dir(s)
include_directories(${FOGLAMP_INCLUDE_DIRS})
# Add other include paths this plugin needs
if (FOGLAMP_SRC)
message(STATUS "Using third-party includes " ${FOGLAMP_SRC}/C/thirdparty/Simple-Web-Server)
include_directories(${FOGLAMP_SRC}/C/thirdparty/Simple-Web-Server)
else()
include_directories(${FOGLAMP_INCLUDE_DIRS}/Simple-Web-Server)
endif()
# Add FogLAMP lib path
link_directories(${FOGLAMP_LIB_DIRS})
# Create shared library
add_library(${PROJECT_NAME} SHARED ${SOURCES})
# Add FogLAMP library names
target_link_libraries(${PROJECT_NAME} ${NEEDED_FOGLAMP_LIBS})
# Add additional libraries
target_link_libraries(${PROJECT_NAME} -lssl -lcrypto)
# Set the build version
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 1)
set(FOGLAMP_INSTALL "" CACHE INTERNAL "")
# Install library
if (FOGLAMP_INSTALL)
message(STATUS "Installing ${PROJECT_NAME} in ${FOGLAMP_INSTALL_DIR}/plugins/${PLUGIN_TYPE}/${PROJECT_NAME}")
install(TARGETS ${PROJECT_NAME} DESTINATION ${FOGLAMP_INSTALL_DIR}/plugins/${PLUGIN_TYPE}/${PROJECT_NAME})
endif()