CMakeLists.txt 4.29 KB
Newer Older
florent's avatar
florent committed
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
#
#  Copyright 2010 CNRS-LAAS
#  Author: Florent Lamiraux
#

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

SET(PROJECT_NAME hppCore)
project(${PROJECT_NAME})

SET(PROJECT_VERSION 1.12)

SET(CMAKE_VERBOSE_MAKEFILE true)

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)

#
# Look for dependencies
#

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

#
#  Dependency to package kwsPlus
#
SET(KWSPLUS_FOUND 0)
SET(KWSPLUS_REQUIRED "kwsPlus >= 1.8")
PKG_CHECK_MODULES(KWSPLUS REQUIRED ${KWSPLUS_REQUIRED})
EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS  --variable=docdir kwsPlus
  OUTPUT_VARIABLE KWSPLUS_DOCDIR)
MESSAGE(STATUS "pkg-config: ${PKG_CONFIG_EXECUTABLE}")
MESSAGE(STATUS "KWSPLUS_DOCDIR=${KWSPLUS_DOCDIR}")
SET(KWSPLUS_FOUND 1)

IF(NOT ${KWSPLUS_FOUND})
  MESSAGE(FATAL_ERROR "Check that package kwsPlus is installed in a directory pointed out by PKG_CONFIG_PATH.")
ENDIF(NOT ${KWSPLUS_FOUND})

IF(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS ${KWSPLUS_REQUIRED})
ELSE(PACKAGE_REQUIREMENTS STREQUAL "")
  SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${KWSPLUS_REQUIRED}")
ENDIF(PACKAGE_REQUIREMENTS STREQUAL "")


#
#  Optional Dependency to package hppModel
#
IF (NOT DEFINED ENABLE_BODY)
  SET(ENABLE_BODY NO)
ENDIF(NOT DEFINED ENABLE_BODY)

MESSAGE (STATUS "ENABLE_BODY "${ENABLE_BODY})

IF(${ENABLE_BODY} STREQUAL YES)
  MESSAGE(STATUS "using internal implementation of ChppBody")
  SET(BODY_CFLAGS "IMPLEMENT_BODY=1")
  SET(BODY_HEADER_PATH="hppModel")
ELSE(${ENABLE_BODY} STREQUAL YES)
  MESSAGE(STATUS "using external implementation of ChppBody")
  SET(HPPMODEL_FOUND 0)
  SET(HPPMODEL_REQUIRED "hppModel >= 1.7.6")
  PKG_CHECK_MODULES(HPPMODEL REQUIRED ${HPPMODEL_REQUIRED})
  EXEC_PROGRAM(${PKG_CONFIG_EXECUTABLE} ARGS  --variable=docdir hppModel
    OUTPUT_VARIABLE HPPMODEL_DOCDIR)
  MESSAGE(STATUS "pkg-config: ${PKG_CONFIG_EXECUTABLE}")
  MESSAGE(STATUS "HPPMODEL_DOCDIR=${HPPMODEL_DOCDIR}")
  SET(HPPMODEL_FOUND 1)

  IF(NOT ${HPPMODEL_FOUND})
    MESSAGE(FATAL_ERROR "Check that package hppModel is installed in a directory pointed out by PKG_CONFIG_PATH.")
  ENDIF(NOT ${HPPMODEL_FOUND})

  IF(PACKAGE_REQUIREMENTS STREQUAL "")
    SET(PACKAGE_REQUIREMENTS ${HPPMODEL_REQUIRED})
  ELSE(PACKAGE_REQUIREMENTS STREQUAL "")
    SET(PACKAGE_REQUIREMENTS "${PACKAGE_REQUIREMENTS}, ${HPPMODEL_REQUIRED}")
  ENDIF(PACKAGE_REQUIREMENTS STREQUAL "")
ENDIF(${ENABLE_BODY} STREQUAL YES)

#
# 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 lib/pkgconfig)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.cmake
  ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
  DESTINATION ${install_libdir_pkgconfig}
  PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(include)

#
# Documentation produced by doxygen
#
INCLUDE(FindDoxygen)
IF(DOXYGEN_FOUND)
  add_subdirectory(doc)
ENDIF(DOXYGEN_FOUND)

#
# Uninstall target
#
CONFIGURE_FILE(
  ${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in
  ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
  IMMEDIATE )

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

#
# Package
#
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "hppCore")
set(CPACK_PACKAGE_VENDOR "Your laboratory")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Your name")
set(CPACK_GENERATOR DEB)
set(
CPACK_SOURCE_PACKAGE_FILE_NAME
"hppCore-${PROJECT_VERSION}"
CACHE INTERNAL "tarball basename"
)
set(CPACK_SOURCE_GENERATOR TGZ)

set(CPACK_SOURCE_IGNORE_FILES
"~$""^${PROJECT_SOURCE_DIR}/build/"
"^${PROJECT_SOURCE_DIR}/.git/"
)
include(CPack)