-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (105 loc) · 3.14 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
#####################################
## Option part
#####################################
option(semaphore_build_samples "Build semaphore sample programs." OFF)
option(compile_with_debug "Build library with debug." 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}/libJPSemaphores.so )
return()
ENDIF()
SET(LIBRARY_OUTPUT_PATH .)
SET(EXECUTABLE_OUTPUT_PATH .)
#####################################
## Project name
#####################################
PROJECT(Semaphores)
#####################################
## Include directories
#####################################
INCLUDE_DIRECTORIES( include lib ${INSTALL_LIBS} ${INSTALL_INCS})
#####################################
## Folders to be build
#####################################
ADD_SUBDIRECTORY( src lib )
#ADD_SUBDIRECTORY( exampleProgram bin )
#####################################
## Samples to be build
#####################################
if( semaphore_build_samples)
ADD_SUBDIRECTORY( exampleProgram bin )
endif()
#####################################
# Search for needed lib
#####################################
FIND_LIBRARY( CPPJPLOGGER_LIB NAMES logger
PATHS ${LOCAL_LIBS} ${INSTALL_LIBS} )
find_library(logger REQUIRED)
include_directories(${logger_INCLUDE_DIRS})
#####################################
# Instalation section
#####################################
INSTALL( FILES include/libJPSemaphores.hpp
DESTINATION ${INSTALL_INCS} )
INSTALL( FILES lib/libJPSemaphoresStatic.a
DESTINATION ${INSTALL_LIBS} )
INSTALL( FILES lib/libJPSemaphores.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
Makefile
core core.*
gmon.out
*~
lib
CMakeFiles
bin
install_*
cmake_install.cmake
doc/docs/
doc/semaphore.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}/doc/semaphore.dox.in ${CMAKE_CURRENT_BINARY_DIR}/doc/semaphore.dox @ONLY)
add_custom_target(docs
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/semaphore.dox
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating Semaphore documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)