-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·75 lines (57 loc) · 2.03 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
cmake_minimum_required( VERSION 3.5 )
project( common VERSION 0.2 LANGUAGES CXX )
include(cmake/definitions.cmake )
include(cmake/dirs.cmake)
# NOTE: CMAKE_BUILD_TYPE can and should be overriden by the IDE
if(CMAKE_BUILD_TYPE MATCHES "Debug")
message("Building in DEBUG mode, enabling testing macros.")
add_definitions(-DTESTING)
endif()
set(HEADERS
functional.h
io.h
numeric.h
patterns.h
stack.h
stackcontainer.h
tools.h
trees.h
thread.h
)
set(SOURCES
# empty, just to help cMake determine language
numeric.cpp
thread.cpp
)
add_library(common SHARED ${HEADERS} ${SOURCES})
set_target_properties(common PROPERTIES VERSION ${PROJECT_VERSION})
message( "CMAKE_CXX_COMPILER_VERSION; ${CMAKE_CXX_COMPILER_VERSION}" )
set( MAJOR "")
STRING(REGEX REPLACE "^([0-9]+)\\.+.*" "\\1" MAJOR "${CMAKE_CXX_COMPILER_VERSION}")
message( "MAJOR; ${MAJOR}" )
set( LIBSUFFIX "${CMAKE_CXX_COMPILER_ID}${MAJOR}" )
if( CMAKE_EXE_LINKER_FLAGS MATCHES "lc\\+\\+" )
set( LIBSUFFIX "${LIBSUFFIX}libc++")
message( "Using libc++")
endif()
if( ${CMAKE_BUILD_TYPE} MATCHES "Debug")
set( LIBSUFFIX "${LIBSUFFIX}-d")
message( "Using debug")
endif()
string( TOLOWER ${LIBSUFFIX} LIBSUFFIX)
message( "Generated suffix; ${LIBSUFFIX}" )
#set_target_properties(common PROPERTIES SUFFIX "-${LIBSUFFIX}" )
set_target_properties(common PROPERTIES LIBRARY_OUTPUT_NAME "${PROJECT_NAME}-${LIBSUFFIX}" )
#set_target_properties(common PROPERTIES OUTPUT_NAME "${LIBRARY_OUTPUT_NAME}-${LIBSUFFIX}" )
message( "Output_Name; ${OUTPUT_NAME}" )
message( "Name; ${NAME}" )
message( "LIBRARY_OUTPUT_NAME; ${LIBRARY_OUTPUT_NAME}" )
# public api
set_target_properties(common PROPERTIES PUBLIC_HEADER "${HEADERS}" )
include(GNUInstallDirs)
set(CMAKE_INSTALL_PREFIX "/usr/local")
message( "Install prefix:" ${CMAKE_INSTALL_PREFIX})
install(TARGETS common
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" #${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include/common" #${CMAKE_INSTALL_INCLUDEDIR}
)