forked from StoccoDavide/acme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
116 lines (99 loc) · 3.99 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
CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )
SET( CMAKE_VERBOSE_MAKEFILE OFF )
SET( CMAKE_INSTALL_MESSAGE NEVER )
PROJECT( acme )
INCLUDE( ./CMakeLists-cflags.txt )
IF ( BUILD_SHARED )
IF ( APPLE )
SET( TARGET acme_osx )
ELSEIF( LINUX OR UNIX )
SET( TARGET acme_linux )
ELSE()
SET( TARGET acme_win_${BITS} )
SET( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON )
ENDIF()
ENDIF()
IF ( APPLE )
SET( TARGETS acme_osx_static )
ELSEIF( LINUX OR UNIX )
SET( TARGETS acme_linux_static )
ELSE()
SET( TARGETS acme_win_${BITS}_static )
ENDIF()
MESSAGE( STATUS "Compiler used: ${CMAKE_CXX_COMPILER_ID}")
SET( CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )
SET( CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} )
SET( EIGEN3_INCLUDE_DIR "${EIGEN3_INCLUDE_DIR}" )
IF( NOT EIGEN3_INCLUDE_DIR )
MESSAGE( FATAL_ERROR "Please point the environment variable EIGEN3_INCLUDE_DIR to the include directory of your Eigen3 installation.")
ENDIF()
INCLUDE_DIRECTORIES ( "${EIGEN3_INCLUDE_DIR}" )
SET( SOURCES )
FILE( GLOB S ./src/*.cc )
FOREACH (F ${S})
FILE( RELATIVE_PATH RF ${CMAKE_CURRENT_SOURCE_DIR} "${F}" )
LIST( APPEND SOURCES ${RF} )
ENDFOREACH (F ${S})
SET( HEADERS )
FILE( GLOB S ./include/*.hh )
FOREACH (F ${S})
FILE( RELATIVE_PATH RF ${CMAKE_CURRENT_SOURCE_DIR} "${F}" )
LIST( APPEND HEADERS ${RF} )
ENDFOREACH (F ${S})
INCLUDE_DIRECTORIES( ./include/ ./src/ )
SET( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/lib )
IF ( BUILD_SHARED )
ADD_LIBRARY( ${TARGETS} STATIC ${SOURCES} )
ADD_LIBRARY( ${TARGET} SHARED ${SOURCES} )
INSTALL(
TARGETS ${TARGET} ${TARGETS}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/dll
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
ELSE()
ADD_LIBRARY( ${TARGETS} STATIC ${SOURCES} ${HEADERS} )
INSTALL(
TARGETS ${TARGETS}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/dll
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
ENDIF()
SET_PROPERTY( TARGET ${TARGETS} PROPERTY POSITION_INDEPENDENT_CODE ON )
INSTALL( FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include )
IF( BUILD_EXECUTABLE )
SET( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin )
FILE( MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin )
FILE( GLOB S ./tests/*.cc )
FOREACH( F ${S} )
FILE( RELATIVE_PATH RF ${CMAKE_CURRENT_SOURCE_DIR} "${F}" )
GET_FILENAME_COMPONENT( TEXE ${RF} NAME_WE )
ADD_EXECUTABLE( ${TEXE} ${RF} )
IF ( UNIX )
TARGET_LINK_LIBRARIES( ${TEXE} ${TARGETS} -ldl )
ELSE()
TARGET_LINK_LIBRARIES( ${TEXE} ${TARGETS} )
ENDIF()
ENDFOREACH( F ${S} )
ENDIF()
SET_PROPERTY( TARGET ${TARGETS} PROPERTY POSITION_INDEPENDENT_CODE ON )
INSTALL( FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include )
MESSAGE( STATUS "Using ${SSE_FLAGS} extensions")
MESSAGE( STATUS "C compiler = ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER}" )
MESSAGE( STATUS "C++ compiler = ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER}" )
MESSAGE( STATUS "CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}" )
MESSAGE( STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}" )
MESSAGE( STATUS "CMAKE_C_FLAGS_RELEASE = ${CMAKE_C_FLAGS_RELEASE}" )
MESSAGE( STATUS "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}" )
MESSAGE( STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}" )
MESSAGE( STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}" )
IF(APPLE)
MESSAGE( STATUS "CMAKE_OSX_SYSROOT = ${CMAKE_OSX_SYSROOT}" )
MESSAGE( STATUS "CMAKE_OSX_ARCHITECTURES = ${CMAKE_OSX_ARCHITECTURES}" )
MESSAGE( STATUS "CMAKE_OSX_DEPLOYMENT_TARGET = ${CMAKE_OSX_DEPLOYMENT_TARGET}" )
ENDIF()
MESSAGE( STATUS "CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}" )
MESSAGE( STATUS "EIGEN3_INCLUDE_DIR = ${EIGEN3_INCLUDE_DIR}" )
MESSAGE( STATUS "BUILD_SHARED = ${BUILD_SHARED}" )
MESSAGE( STATUS "BUILD_EXECUTABLE = ${BUILD_EXECUTABLE}" )