CMakeLists.txt 6.09 KB
Newer Older
1
2
3
4
5
6
#
#  Copyright
#

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

7
SET(PROJECT_NAME dynamic-graph)
8
9
project(${PROJECT_NAME})

10
11
12
13
14
15
# --- PROJECT VERSION -----------------------
SET(${PROJECT_NAME}_VERSION_MAJOR "1")
SET(${PROJECT_NAME}_VERSION_MINOR "0")
SET(${PROJECT_NAME}_VERSION_PATCH "0")
SET(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}")
SET(PROJECT_VERSION ${${PROJECT_NAME}_VERSION})
16
17
18

SET(CMAKE_VERBOSE_MAKEFILE true)

19
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
20
21
22
23
24
25
26

# Get the OS
SET(OS ${CMAKE_SYSTEM_NAME})

#----------------------------------------------------
# --- GENERIC FLAGS ---------------------------------
#----------------------------------------------------
27
28
29
# For CMAKE Modules
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")

30
# Specify the compile flags for the overall library.
31
32
33
34
35
36
37
38
39
40
41
42
IF(WIN32)
  SET(LIBDIR_KW "/LIBPATH:")
  SET(LIBINCL_KW "")
  SET(LIB_EXT ".lib")
ENDIF(WIN32)

IF(UNIX)
  SET(LIBDIR_KW "-L")
  SET(LIBINCL_KW "-l")
  SET(LIB_EXT "")
ENDIF(UNIX)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Link flags
SET(${PROJECT_NAME}_LINK_SRC_FLAGS "")
SET(${PROJECT_NAME}_LINK_FLAGS "${LIBDIR_KW}${${PROJECT_NAME}_BINARY_DIR}/lib ")
SET(${PROJECT_NAME}_LINK_FLAGS "${${PROJECT_NAME}_LINK_FLAGS} ${LIBINCLUSION_KW}${${PROJECT_NAME}_INTERN_LIBS}${LIBINCLUSION_EXT}")
IF(UNIX)
  SET(${PROJECT_NAME}_LINK_SRC_FLAGS "${${PROJECT_NAME}_LINK_SRC_FLAGS} -ldl")
  SET(${PROJECT_NAME}_LINK_FLAGS "${${PROJECT_NAME}_LINK_FLAGS} -ldl")
ENDIF(UNIX)

# Release flags
IF(\"${CMAKE_BUILD_TYPE}\" STREQUAL \"\" )
ELSE(\"${CMAKE_BUILD_TYPE}\" STREQUAL \"\" )
  IF(${CMAKE_BUILD_TYPE} STREQUAL DEBUG)
    SET(${PROJECT_NAME}_CXXFLAGS ${CMAKE_CXX_FLAGS_DEBUG}) # Useless since CXX_FLAGS, not CXXFLAGS.
57
    ADD_DEFINITIONS(-DVP_DEBUG -DVP_DEBUG_MODE=15)
58
59
60
61
62
63
64
65
  ENDIF(${CMAKE_BUILD_TYPE} STREQUAL DEBUG)
  IF(${CMAKE_BUILD_TYPE} STREQUAL RELEASE)
    SET(${PROJECT_NAME}_CXXFLAGS ${CMAKE_CXX_FLAGS_RELEASE}) # Same here.
  ENDIF(${CMAKE_BUILD_TYPE} STREQUAL RELEASE)
ENDIF (\"${CMAKE_BUILD_TYPE}\" STREQUAL \"\")

# --- Default options -------------------------------------------------
OPTION(BUILD_SHARED_LIBS "Build ${PROJECT_NAME} with shared libraries." ON)
florent's avatar
florent committed
66
OPTION(GENERATE_DOC "Generate html documentation" ON)
67

Olivier Stasse's avatar
Olivier Stasse committed
68
69
70
71
72
73
74
# --- BOOST ---------------------------------------------------
SET(Boost_THREAD_FOUND 0)
FIND_PACKAGE(Boost COMPONENTS thread)
IF(Boost_THREAD_FOUND)
  #MESSAGE(STATUS "Boost_THREAD_LIBRARY:" ${Boost_THREAD_LIBRARY})
  #MESSAGE(STATUS "Boost_THREAD_LIBRARY_RELEASE:" ${Boost_THREAD_LIBRARY_RELEASE})
  #MESSAGE(STATUS "Boost_THREAD_LIBRARY_DEBUG:" ${Boost_THREAD_LIBRARY_DEBUG})
75
76
	
	ADD_DEFINITIONS(-DHAVE_LIBBOOST_THREAD)
Olivier Stasse's avatar
Olivier Stasse committed
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

  # Look for the type of pattern to find.
  SET(BOOST_PATTERN_TOFIND "")
  IF(${CMAKE_BUILD_TYPE} MATCHES RELEASE)
    SET(BOOST_PATTERN_TOFIND optimized)
  ENDIF(${CMAKE_BUILD_TYPE} MATCHES RELEASE)
  IF(${CMAKE_BUILD_TYPE} MATCHES DEBUG)
    SET(BOOST_PATTERN_TOFIND debug)
  ENDIF(${CMAKE_BUILD_TYPE} MATCHES DEBUG)

  IF(BOOST_PATTERN_TOFIND)
    SET(BOOST_THREAD_LIST_LENGTH 0)
    LIST(LENGTH Boost_THREAD_LIBRARY BOOST_THREAD_LIST_LENGTH)
    # Debug or optimized library.
    IF(${BOOST_THREAD_LIST_LENGTH} MATCHES 4)
      LIST(FIND Boost_THREAD_LIBRARY ${BOOST_PATTERN_TOFIND} BTLB_index)
      LIST(REMOVE_AT Boost_THREAD_LIBRARY ${BTLB_index})
      LIST(GET Boost_THREAD_LIBRARY ${BTLB_index} BOOST_THREAD_LIB_NAME)
    # Default strategy
    ELSE(${BOOST_THREAD_LIST_LENGTH} MATCHES 4)
      SET(BOOST_THREAD_LIB_NAME ${Boost_THREAD_LIBRARY})
    ENDIF(${BOOST_THREAD_LIST_LENGTH} MATCHES 4)
  # Default strategy
  ELSE(BOOST_PATTERN_TOFIND)
    SET(BOOST_THREAD_LIB_NAME  ${Boost_THREAD_LIBRARY})
  ENDIF(BOOST_PATTERN_TOFIND)

104
105
106
107
108
109
110
111
112
113
114
  # --- PTHREAD -------------------------------------------------------
  FIND_PACKAGE(PTHREAD REQUIRED)
  IF(PTHREAD_FOUND)
    ADD_DEFINITIONS(-DHAVE_PTHREAD)
    IF(UNIX)
    	ADD_DEFINITIONS(-pthread)
    ENDIF(UNIX)
    INCLUDE_DIRECTORIES(${PTHREAD_INCLUDE_DIRS})
	LINK_DIRECTORIES(${PTHREAD_LIBRARY_DIRS})
  ENDIF(PTHREAD_FOUND)
  
Olivier Stasse's avatar
Olivier Stasse committed
115
116
117
118
119
120
121
122
123
124
125
126
ELSE(Boost_THREAD_FOUND)
  MESSAGE("WARNING: Boost thread not found. Trying without the thread library")
  FIND_PACKAGE(Boost)
  IF(NOT Boost_FOUND)
	MESSAGE(SEND_ERROR "!! ERROR: Boost not found.")
  ENDIF(NOT Boost_FOUND)
ENDIF(Boost_THREAD_FOUND)
MESSAGE(STATUS "Boost thread lib name: ${BOOST_THREAD_LIB_NAME} ${Boost_THREAD_LIBRARY}")

INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})

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
#
# Look for dependencies
#

# Load Pkgconfig macros
INCLUDE(FindPkgConfig)
SET(PACKAGE_REQUIREMENTS "")

#
# pkg-config file
#

SET(install_pkg_prefix "\${prefix}")
SET(install_pkg_exec_prefix "\${exec_prefix}")
SET(install_pkg_libdir "\${libdir}")
SET(install_pkg_datarootdir "\${datarootdir}")
SET(install_pkg_include_dir "\${includedir}")

IF(UNIX)
  SET (${PROJECT_NAME}_LDFLAGS "-Wl,-R${install_pkg_libdir} ${LIBINCL_KW}${PROJECT_NAME}${LIB_EXT} ${${PROJECT_NAME}_LDFLAGS}")
ENDIF(UNIX)

IF(WIN32)
  SET (${PROJECT_NAME}_LDFLAGS "${LIBINCL_KW}${PROJECT_NAME}${LIB_EXT} ${${PROJECT_NAME}_LDFLAGS}")
ENDIF(WIN32)

# Install the file in the appropriate place.
SET(install_libdir_pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)

156
157
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/dynamic-graph.pc.cmake
  ${CMAKE_CURRENT_BINARY_DIR}/dynamic-graph.pc)
158

159
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/dynamic-graph.pc
160
161
162
  DESTINATION ${install_libdir_pkgconfig}	
  PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)

163
164
165
166
167
168
169
170
171
172
# Uninstall target.
CONFIGURE_FILE(
  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)

ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

# Testing 
173
174
ENABLE_TESTING()

175
176
177
178
IF(WIN32)
  ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /wd4251 /wd4275 /wd4101 /wd4355")
ENDIF(WIN32)

179
180
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(include)
181
ADD_SUBDIRECTORY(tools)
Francois Bleibel's avatar
Francois Bleibel committed
182
ADD_SUBDIRECTORY(unitTesting)
183

184
185
186
#
# Documentation produced by doxygen
#
187
188
189
190
191
192
193
IF(GENERATE_DOC)
  INCLUDE(FindDoxygen)
  IF(DOXYGEN_FOUND)
    MESSAGE(STATUS "Doxygen found")
    add_subdirectory(doc)
  ENDIF(DOXYGEN_FOUND)
ENDIF(GENERATE_DOC)