CMakeLists.txt 5.18 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
27

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

#----------------------------------------------------
# --- GENERIC FLAGS ---------------------------------
#----------------------------------------------------
# Specify the compile flags for the overall library.
28
29
30
31
32
33
34
35
36
37
38
39
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)

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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.
  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)
OPTION(GENERATE_DOC "Generate html documentation" OFF)

Olivier Stasse's avatar
Olivier Stasse committed
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
# --- 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})

  # 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)

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})

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
#
# 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)

139
140
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/dynamic-graph.pc.cmake
  ${CMAKE_CURRENT_BINARY_DIR}/dynamic-graph.pc)
141

142
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/dynamic-graph.pc
143
144
145
  DESTINATION ${install_libdir_pkgconfig}	
  PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)

146
147
ENABLE_TESTING()

148
149
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(include)
150
ADD_SUBDIRECTORY(tools)
Francois Bleibel's avatar
Francois Bleibel committed
151
ADD_SUBDIRECTORY(unitTesting)
152

153
154
155
#
# Documentation produced by doxygen
#
156
157
158
159
160
161
162
IF(GENERATE_DOC)
  INCLUDE(FindDoxygen)
  IF(DOXYGEN_FOUND)
    MESSAGE(STATUS "Doxygen found")
    add_subdirectory(doc)
  ENDIF(DOXYGEN_FOUND)
ENDIF(GENERATE_DOC)