-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·140 lines (123 loc) · 3.89 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
#####################################
## Option part
#####################################
option(logger_build_samples "Build logger sample programs." OFF)
option(compile_with_debug "Build library with debug." OFF)
option(force_boost "Force BOOST usage instead of C++11." OFF)
#####################################
## Definition of environment
#####################################
IF( DEFINED ENV{INSTALL_LIB_DIR} )
SET(INSTALL_LIBS $ENV{INSTALL_LIB_DIR}/ )
ELSE()
SET(INSTALL_LIBS ${CMAKE_HOME_DIRECTORY}/lib )
ENDIF()
IF( DEFINED ENV{INSTALL_INC_DIR} )
SET(INSTALL_INCS $ENV{INSTALL_INC_DIR}/ )
ELSE()
SET(INSTALL_INCS ${CMAKE_HOME_DIRECTORY}/include )
ENDIF()
IF( EXISTS ${INSTALL_LIBS}/liblogger.so )
return()
ENDIF()
SET(LIBRARY_OUTPUT_PATH .)
SET(EXECUTABLE_OUTPUT_PATH .)
#####################################
## Project name
#####################################
PROJECT(logger)
#####################################
## Include directories
#####################################
INCLUDE_DIRECTORIES( include lib )
find_package (Threads REQUIRED)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT force_boost)
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
message("GCC Without c++11")
FIND_PACKAGE( Boost 1.40 COMPONENTS program_options REQUIRED )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
ADD_DEFINITIONS( -DUSE_BOOST_INSTEAD_CXX11 ${CMAKE_THREAD_LIBS_INIT} )
SET(ADDITIONAL_LINK_LIBS boost_system)
else()
message("GCC With c++11")
ADD_DEFINITIONS( -std=c++11 ${CMAKE_THREAD_LIBS_INIT} )
SET(ADDITIONAL_LINK_LIBS )
endif ()
else ()
message("Force Boost")
FIND_PACKAGE( Boost 1.40 COMPONENTS program_options REQUIRED )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
ADD_DEFINITIONS( -DUSE_BOOST_INSTEAD_CXX11 ${CMAKE_THREAD_LIBS_INIT} )
SET(ADDITIONAL_LINK_LIBS boost_system)
endif ()
#####################################
## Folders to be build
#####################################
ADD_SUBDIRECTORY( src lib )
#####################################
## Samples to be build
#####################################
if( logger_build_samples)
ADD_SUBDIRECTORY( exampleProgram bin )
endif()
#####################################
# Search for needed lib
#####################################
#####################################
# Instalation section
#####################################
INSTALL( FILES include/libJPLogger.hpp
DESTINATION ${INSTALL_INCS} )
INSTALL( FILES lib/libJPLoggerStatic.a
DESTINATION ${INSTALL_LIBS} )
INSTALL( FILES lib/libJPLogger.so
DESTINATION ${INSTALL_LIBS} )
#####################################
# Others
#####################################
IF( UNIX )
ADD_CUSTOM_TARGET( distclean @@echo cleaning for source distribution)
SET(DISTCLEANED
cmake.depends
cmake.check_depends
CMakeCache.txt
cmake.check_cache
*.cmake
Makefile
core core.*
gmon.out
*~
lib
CMakeFiles
bin
install_*
docs/docs/
docs/logger.dox
)
ADD_CUSTOM_COMMAND(
DEPENDS clean
COMMENT "distribution clean"
COMMAND rm
ARGS -Rf CMakeTmp ${DISTCLEANED}
TARGET distclean
)
ENDIF( UNIX )
if( compile_with_debug )
set(CMAKE_CXX_FLAGS "-DDEBUG=1")
set(CMAKE_BUILD_TYPE Debug)
endif()
#####################################
# add a target to generate API documentation with Doxygen
#####################################
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/logger.dox.in ${CMAKE_CURRENT_BINARY_DIR}/docs/logger.dox @ONLY)
add_custom_target(docs
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/logger.dox
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating Logger documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)