-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGeneric.cmake
173 lines (141 loc) · 4.32 KB
/
Generic.cmake
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#INCLUDE(TestForSTDNamespace)
#
# Threads
#
#INCLUDE(FindThreads)
# project() option must be used later
IF(WITH_LLVM)
MESSAGE(STATUS "llvm/clang enabled")
SET(CMAKE_C_COMPILER clang)
SET(CMAKE_CXX_COMPILER clang++)
ENDIF(WITH_LLVM)
enable_language(CXX C)
IF(NOT CMAKE_BUILD_TYPE)
SET (CMAKE_BUILD_TYPE "RELEASE")
MESSAGE(STATUS "default build type set to RELEASE")
ELSE(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "configuring for ${CMAKE_BUILD_TYPE}...")
ENDIF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_CXX_FLAGS "${CXXFLAGS} ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual " )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -W -pedantic -Wno-long-long -Wformat ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros " )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfloat-equal -Wdisabled-optimization " )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter " )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-default-inline " )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -D_THREAD_SAFE -pipe" )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE" )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g -ggdb" )
SET(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -Og -D_FORTIFY_SOURCE=2 -fno-strict-aliasing -fno-omit-frame-pointer")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
IF(WITH_PGO STREQUAL "generate")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-generate")
MESSAGE(STATUS "${WITH_PGO} pgo profile...")
ELSE(WITH_PGO STREQUAL "generate")
IF(WITH_PGO STREQUAL "use")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-use")
MESSAGE(STATUS "${WITH_PGO} pgo profile...")
ENDIF(WITH_PGO STREQUAL "use")
ENDIF(WITH_PGO STREQUAL "generate")
INCLUDE(CheckIncludeFileCXX)
INCLUDE(CheckLibraryExists)
SET(EXECUTABLE_OUTPUT_PATH bin)
SET(LIBRARY_OUTPUT_PATH lib)
INCLUDE_DIRECTORIES(include)
#
# Doxygen
#
FIND_PACKAGE(Doxygen)
IF(DOXYGEN_FOUND)
ADD_CUSTOM_TARGET (doxygen ${DOXYGEN_EXECUTABLE} WORKING_DIRECTORY ${PROJ_SOURCE_DIR} COMMENT "Generating documentation")
ELSE(DOXYGEN_FOUND)
MESSAGE(STATUS "doxygen documentation unavailable")
ENDIF(DOXYGEN_FOUND)
#
# ctags
#
ADD_CUSTOM_TARGET (tags ctags -R WORKING_DIRECTORY ${PROJ_SOURCE_DIR} COMMENT "Generating tags")
#
# Debian package
#
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "urykhy")
INCLUDE(CPack)
#
# OS detect
#
#
# debug path
#
#IF(${CMAKE_BUILD_TYPE} MATCHES "DEBUG")
# LINK_DIRECTORIES(/usr/lib/debug)
#ENDIF(${CMAKE_BUILD_TYPE} MATCHES "DEBUG")
#
# lib-tut TESTS
#
FIND_PATH(LIBTUT_INCLUDE
NAMES tut.hpp
PATHS /usr/include/tut/
/opt/include/tut/
/usr/local/include/tut/
/usr/local/tut/include
DOC "tut.hpp ")
IF(LIBTUT_INCLUDE)
ENABLE_TESTING()
INCLUDE_DIRECTORIES(${LIBTUT_INCLUDE})
MACRO(GEN_ADD_TEST binname srcname lib )
ADD_EXECUTABLE(${binname} ${srcname} )
TARGET_LINK_LIBRARIES(${binname} ${lib} ${LLIB})
ADD_TEST(${binname} ./bin/${binname} )
MESSAGE(STATUS "libtut test added :: ${srcname}")
ENDMACRO(GEN_ADD_TEST)
ELSE(LIBTUT_INCLUDE)
MACRO(GEN_ADD_TEST binname srcname lib )
MESSAGE(STATUS "libtut unavailable, skipped :: ${srcname}")
ENDMACRO(GEN_ADD_TEST)
ENDIF(LIBTUT_INCLUDE)
#
# scan LLIB variable
#
GET_DIRECTORY_PROPERTY(PROJECT_LINK LINK_DIRECTORIES )
FOREACH(LNAME ${LLIB})
FIND_LIBRARY( HAVE_${LNAME}
NAMES ${LNAME}
PATHS
${PROJECT_LINK}
/usr/lib
/opt/lib
/usr/local/lib
PATH_SUFFIXES ${SEARCHIN})
IF( HAVE_${LNAME} )
GET_FILENAME_COMPONENT(HAVE_${LNAME}_IN ${HAVE_${LNAME}} PATH)
MESSAGE(STATUS "Found ${LNAME} IN ${HAVE_${LNAME}_IN}")
LINK_DIRECTORIES( ${HAVE_${LNAME}_IN} )
ELSE(HAVE_${LNAME})
MESSAGE(FATAL_ERROR "${LNAME} library not found")
ENDIF(HAVE_${LNAME})
ENDFOREACH(LNAME)
#
# scan HDRS variable
#
GET_DIRECTORY_PROPERTY(PROJECT_INCLUDES INCLUDE_DIRECTORIES )
FOREACH(HNAME ${HDRS})
FIND_PATH( HAVE_${HNAME}
NAMES ${HNAME}
PATHS
${PROJECT_INCLUDES}
/usr/include
/opt/include
/usr/local/include
PATH_SUFFIXES ${SEARCHIN})
IF(HAVE_${HNAME})
MESSAGE(STATUS "Found ${HNAME} in ${HAVE_${HNAME}}")
INCLUDE_DIRECTORIES( ${HAVE_${HNAME}} )
ELSE(HAVE_${HNAME})
MESSAGE(FATAL_ERROR "${HNAME} not found")
ENDIF(HAVE_${HNAME})
ENDFOREACH(HNAME)
IF(WITH_TCMALLOC)
MESSAGE(STATUS "tcmalloc enabled")
SET (LLIB ${LLIB} tcmalloc)
ENDIF(WITH_TCMALLOC)