CMakeLists.txt 15.8 KB
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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
#=============================================================================
# CMakeLists.txt - Rules for nd-view target.
#
# Generated by coolbot-bundle version 1.0.0
#=============================================================================

MESSAGE("")
MESSAGE(STATUS "Generating nd-view target")

#
# NOTE: You have a file called cmake_targets.cmake in the directory resources/cmake
# Check to see that in this file, you have the following entry:
#
# ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/nd-view)
#
# In the event that the entry is not available, add the line in this file or in
# the main CMakeLists.txt file.
#
# In resources/modules directory is available a file called:
#
# FindND_VIEW.cmake
#
# This file finds and loads settings from this project and it is used to
# facilitate the use of this project in others. You must review this file and
# edit it.
#

#
# Sets the version of library.
#
SET(MAJOR    1)
SET(MINOR    0)
SET(REVISION 0)
SET(ND_VIEW_VERSION "${MAJOR}.${MINOR}.${REVISION}" CACHE STRING "project version")
SET(ND_VIEW_API_VERSION "${MAJOR}.${MINOR}" CACHE STRING "API version")

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/nd-view)

#
# NOTE: It is preferable not to use the AUX_SOURCE_DIRECTORY command. It is
# recommended to manually specify the source files and header. For example:
#
# SET(ND_VIEW_SRCS
#     src/source.cpp
#     src/source1.cpp
#     ...
#     src/sourceN.cpp
# )
#
# SET(ND_VIEW_HDRS
#     src/header.h
#     src/header1.h
#     ...
#     src/headerN.h
# )
#
# SET(ND_VIEW_MAIN_SOURCE_FILES
#     ${ND_VIEW_SRCS}
#     ${ND_VIEW_HDRS})
#
AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/nd-view"
                      ND_VIEW_MAIN_SOURCE_FILES)

IF(SHOW_DEBUG_INFO)
  MESSAGE(STATUS "Source code of nd-view target:")
  MESSAGE("${ND_VIEW_MAIN_SOURCE_FILES}")
ENDIF(SHOW_DEBUG_INFO)

#
# Flags for the construction of the target nd-view.
# By default, sets the CoolBOT framework flags.
# Here, you should add the flags you need. You can use the RUN_PKGCONFIG macro:
#
#     RUN_PKGCONFIG( <pkg-config option>
#                    <pkg-config file>
#                    <result of the execution>
#                    <output variable with the flags> )
#
# By default, searches for the file in the path established by the tool
# pkg-config.
#
# NOTE: The RUN_PKGCONFIG macro accepts an optional parameter that indicates
# the path where the file pkg-config:
#
#     RUN_PKGCONFIG( <pkg-config option>
#                    <pkg-config file>
#                    <result of the execution>
#                    <output variable with the flags>
#                    <pkg-config file path> )
#
# In this case, the pkg-config file must be extension ".pc".
#
# In addition, you can use the following macros:
#
#     FIND_PKGCONFIG_MODULE( <pkg-config module file name>
#                            <pkg-config module file is within bundle>
#                            <output variable with linker flags>
#                            <output variable with compiler flags>
#                            <output variable  with the result of the operation>
#                            <pkg-config file path> )
#
# This macro searches if the pkg-config module file exists. If the module exists
# gets flags for compiling and linked.
#
#     MY_FIND_PACKAGE( <CMake package name>
#                      <pkg-config module file name>
#                      <output variable with linker flags>
#                      <output variable with compiler flags> )
#
# This macro searches if the CMake module file exists. If the CMake module exists
# gets flags for compiling and linked.
#
#     LOAD_PKGCONFIG_MODULE( module_name
#                            module_is_within_bundle
#                            result
#                            output_module_linker_flags
#                            output_module_compiler_flags
#                            pkgconfig_directory_path )
#
# This macro calls the macro: FIND_PKGCONFIG_MODULE and displays messages about
# the operation performed.
#
#     LOAD_CMAKE_MODULE( module_name
#                        pkgconfig_module_name
#                        output_module_linker_flags
#                        output_module_compiler_flags )
#
# This macro calls the macro: MY_FIND_PACKAGE and displays messages about the
# operation performed.
#
# The ND_VIEW_TARGET_DEPENDENCIES variable indicates if the target
# dependencies are resolved:
#
# - TRUE: The target dependencies are resolved.
#
# - FALSE: Some of the dependencies could not be resolved.
#
# This variable is created in cmake_global_variables.cmake file with the FALSE
# value. It's a variable cache type. You can modify the cache value as follows:
#
# SET(ND_VIEW_TARGET_DEPENDENCIES <value> CACHE INTERNAL "")
#
# where <value> is the value to set.
#

#
# Here you must perform dependencies checking.
#
# NOTE: You have to ask if software dependencies have been resolved and, if so,
# assign the ND_VIEW_TARGET_DEPENDENCIES variable the value TRUE.
#
# For example: This CoolBOT module depends on the software A and B (both external
# bundle) and we have the pkg-config files. Also, this module has a internal
# dependency with C module. In this case, being an internal dependency, we have
# the variable: C_TARGET_DEPENDENCIES. Then:
#
# IF( C_TARGET_DEPENDENCIES )
#
#   SET(PKGCONFIG_FILE_IS_WITHIN_BUNDLE FALSE)
#
#   LOAD_PKGCONFIG_MODULE( "A"
#                          PKGCONFIG_FILE_IS_WITHIN_BUNDLE
#                          A_DEPENDENCIES_RESOLVED
#                          A_LINKER_FLAGS
#                          A_COMPILER_FLAGS
#                          "" )
#
#   LOAD_PKGCONFIG_MODULE( "B"
#                          PKGCONFIG_FILE_IS_WITHIN_BUNDLE
#                          B_DEPENDENCIES_RESOLVED
#                          B_LINKER_FLAGS
#                          B_COMPILER_FLAGS
#                          "" )
#
#   SET(PKGCONFIG_FILE_IS_WITHIN_BUNDLE TRUE)
#
#   LOAD_PKGCONFIG_MODULE( "C"
#                          PKGCONFIG_FILE_IS_WITHIN_BUNDLE
#                          C_DEPENDENCIES_RESOLVED
#                          C_LINKER_FLAGS
#                          C_COMPILER_FLAGS
#                          ${PKG_DIR} )
#
#   IF( A_DEPENDENCIES_RESOLVED AND B_DEPENDENCIES_RESOLVED AND C_DEPENDENCIES_RESOLVED )
#       SET(ND_VIEW_TARGET_DEPENDENCIES TRUE CACHE INTERNAL "")
#   ENDIF( A_DEPENDENCIES_RESOLVED AND B_DEPENDENCIES_RESOLVED AND C_DEPENDENCIES_RESOLVED )
#
# ENDIF( C_TARGET_DEPENDENCIES )
#

IF( PLAYER_ROBOT_PACKETS_TARGET_DEPENDENCIES AND GRID_MAP_TARGET_DEPENDENCIES AND ND_PACKETS_TARGET_DEPENDENCIES AND ND_TARGET_DEPENDENCIES )

  SET(PKGCONFIG_FILE_IS_WITHIN_BUNDLE TRUE)
  LOAD_PKGCONFIG_MODULE( "player-robot-packets"
                        PKGCONFIG_FILE_IS_WITHIN_BUNDLE
                        PLAYER_ROBOT_PACKETS_FOUND
                        PLAYER_ROBOT_PACKETS_LINKER_FLAGS
                        PLAYER_ROBOT_PACKETS_COMPILER_FLAGS
                        ${PKG_DIR} )
                        
  SET(PKGCONFIG_FILE_IS_WITHIN_BUNDLE TRUE)
  LOAD_PKGCONFIG_MODULE( "grid-map"
                        PKGCONFIG_FILE_IS_WITHIN_BUNDLE
                        GRID_MAP_FOUND
                        GRID_MAP_LINKER_FLAGS
                        GRID_MAP_COMPILER_FLAGS
                        ${PKG_DIR} )

  SET(PKGCONFIG_FILE_IS_WITHIN_BUNDLE TRUE)
  LOAD_PKGCONFIG_MODULE( "nd-packets"
                        PKGCONFIG_FILE_IS_WITHIN_BUNDLE
                        ND_PACKETS_FOUND
                        ND_PACKETS_LINKER_FLAGS
                        ND_PACKETS_COMPILER_FLAGS
                        ${PKG_DIR} )

  SET(PKGCONFIG_FILE_IS_WITHIN_BUNDLE TRUE)
  LOAD_PKGCONFIG_MODULE( "nd"
                        PKGCONFIG_FILE_IS_WITHIN_BUNDLE
                        ND_FOUND
                        ND_LINKER_FLAGS
                        ND_COMPILER_FLAGS
                        ${PKG_DIR} )

  IF( PLAYER_ROBOT_PACKETS_FOUND AND GRID_MAP_FOUND AND ND_PACKETS_FOUND AND ND_FOUND)
    SET(ND_VIEW_TARGET_DEPENDENCIES TRUE CACHE INTERNAL "")
  ENDIF( PLAYER_ROBOT_PACKETS_FOUND AND GRID_MAP_FOUND AND ND_PACKETS_FOUND AND ND_FOUND )

ENDIF( PLAYER_ROBOT_PACKETS_TARGET_DEPENDENCIES AND GRID_MAP_TARGET_DEPENDENCIES AND ND_PACKETS_TARGET_DEPENDENCIES AND ND_TARGET_DEPENDENCIES )

IF(NOT ND_VIEW_TARGET_DEPENDENCIES)
  #
  # Show a information message to user. You can use the MESSAGE command:
  #
  #     MESSAGE([STATUS|WARNING|AUTHOR_WARNING|FATAL_ERROR|SEND_ERROR]
  #             "message to display" ...)
  #
  # The optional keyword determines the type of message:
  #
  # - (none): Important information
  # - STATUS: Incidental information
  # - WARNING: CMake Warning, continue processing
  # - AUTHOR_WARNING: CMake Warning (dev), continue processing
  # - SEND_ERROR: CMake Error, continue but skip generation
  # - FATAL_ERROR: CMake Error, stop all processing
  #

  MESSAGE(STATUS "nd-view target can not be generated:")
  IF(NOT PLAYER_ROBOT_PACKETS_FOUND)
    MESSAGE(STATUS "  * player-robot-packets is required.")
  ENDIF(NOT PLAYER_ROBOT_PACKETS_FOUND)
  IF(NOT GRID_MAP_FOUND)
    MESSAGE(STATUS "  * grid-map is required.")
  ENDIF(NOT GRID_MAP_FOUND)
  IF(NOT ND_PACKETS_FOUND)
    MESSAGE(STATUS "  * nd-packets is required.")
  ENDIF(NOT ND_PACKETS_FOUND)
  IF(NOT ND_FOUND)
    MESSAGE(STATUS "  * nd is required.")
  ENDIF(NOT ND_FOUND)

  REGISTER_TARGET_NOT_AVAILABLE("nd-view")

ELSE(NOT ND_VIEW_TARGET_DEPENDENCIES)
  #
  # Sets the compiler and linker flags.
  #
  SET(FLAGS_LIB_COMPILER "${COOLBOT_COMPILER_FLAGS}")
  SET(FLAGS_LIB_LINKER "${COOLBOT_LINKER_FLAGS}")

  SET(FLAGS_LIB_COMPILER "${FLAGS_LIB_COMPILER} ${PLAYER_ROBOT_PACKETS_COMPILER_FLAGS}")
  SET(FLAGS_LIB_LINKER "${FLAGS_LIB_LINKER} ${PLAYER_ROBOT_PACKETS_LINKER_FLAGS}")

  SET(FLAGS_LIB_COMPILER "${FLAGS_LIB_COMPILER} ${GRID_MAP_COMPILER_FLAGS}")
  SET(FLAGS_LIB_LINKER "${FLAGS_LIB_LINKER} ${GRID_MAP_LINKER_FLAGS}")

  SET(FLAGS_LIB_COMPILER "${FLAGS_LIB_COMPILER} ${ND_PACKETS_COMPILER_FLAGS}")
  SET(FLAGS_LIB_LINKER "${FLAGS_LIB_LINKER} ${ND_PACKETS_LINKER_FLAGS}")

  SET(FLAGS_LIB_COMPILER "${FLAGS_LIB_COMPILER} ${ND_COMPILER_FLAGS}")
  SET(FLAGS_LIB_LINKER "${FLAGS_LIB_LINKER} ${ND_LINKER_FLAGS}")

  IF(SHOW_DEBUG_INFO)
    MESSAGE(STATUS "Linker flags of nd-view target:")
    MESSAGE("${FLAGS_LIB_LINKER}")
    MESSAGE(STATUS "Compiler flags of nd-view target:")
    MESSAGE("${FLAGS_LIB_COMPILER}")
  ENDIF(SHOW_DEBUG_INFO)

  #
  # You must add the INCLUDE_DIRS and TARGET_LINK_LIBRARIES who need your project:
  #
  #   INCLUDE_DIRECTORIES(${MY_INCLUDE_DIRS} ${MY_INCLUDE_DIRS_2} ...)
  #
  #   TARGET_LINK_LIBRARIES(nd-view ${MY_LIBRARY} ${MY_LIBRARY_2} ...)
  #
  # The MY_INCLUDE_DIRS contains the path where the headers file and the MY_LIBRARY
  # specifies the libraries to link or linker flags.
  # This can also be specified through the flags.
  #
  # You can also specify in the command TARGET_LINK_LIBRARIES the name of the target
  # defined in the bundle.
  #
  # NOTE: In addition, you can use the command find_package() or MY_FIND_PACKAGE
  # macro to obtain the information necessary for the required packages. In the
  # CMake modules directory you can use existing packages.
  #
  INCLUDE_DIRECTORIES(${COOLBOT_INCLUDE_DIRS})
  ADD_LIBRARY(nd-view ${ND_VIEW_MAIN_SOURCE_FILES})
  TARGET_LINK_LIBRARIES(nd-view
                        player-robot-packets
                        grid-map
                        nd-packets
                        nd
                        ${COOLBOT_LIBRARIES}
                        ${COOLBOT_LINKER_FLAGS}
                        ${PLAYER_ROBOT_PACKETS_LINKER_FLAGS}
                        ${GRID_MAP_LINKER_FLAGS}
                        ${ND_PACKETS_LINKER_FLAGS}
                        ${ND_LINKER_FLAGS}
  )

  SET_TARGET_PROPERTIES(nd-view PROPERTIES
                        LINK_FLAGS    ${FLAGS_LIB_LINKER}
                        COMPILE_FLAGS ${FLAGS_LIB_COMPILER}
                        VERSION       ${ND_VIEW_VERSION}
                        SOVERSION     ${ND_VIEW_API_VERSION})

  IF( WIN32 )
    SET_TARGET_PROPERTIES(nd-view PROPERTIES
                          RUNTIME_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
                          )
  ENDIF( WIN32 )

  #
  # Then, create the file pkg-config which has the following format:
  #
  # prefix=/base/directory/path
  # exec_prefix=${prefix}
  # libdir=${prefix}/lib
  # includedir=${prefix}/include/include-directory
  #
  # prefix_local=/local/base/directory/path
  # libdir_local=${prefix_local}/lib
  # includedir_local=${prefix_local}/include/include-directory
  #
  # Name: <human-readable-name>
  # Description: <human-readable-description>
  # Version: <library-version>
  # Requires: <library-required-packages>
  # Libs: -L${libdir_local} -L${libdir} -l<library-target> <library-linker-flags>
  # Cflags: -I${includedir_local} -I${includedir}
  #
  # The macro CREATE_PKGCONFIG_FILE is responsible for creating this file with the
  # information that you supply.
  #

  CREATE_PKGCONFIG_FILE("${PROJECT_INSTALL_PATH}" # Here the base directory
                        "${PROJECT_SOURCE_DIR}" # Here the local base directory
                        "lib/${BUNDLE_NAME}" # Here the library directory
                        "lib/" # Here the local library directory
                        "include/nd-view" # Here the include directory
                        "nd-view" # Here the local include directory
                        "nd-view" # Here the package name
                        "CoolBOT view NDView - coolbot-sns-bundle" # Here the package description
                        "${ND_VIEW_VERSION}" # Here the package version
                        "player-robot-packets grid-map nd-packets nd" # Here the list of packages that are required by our package
                        "${FLAGS_LIB_LINKER}" # Here the the link flags specific to our package
                        "${PKG_CONFIG_PATH_DIRECTORY}" # This line must not touch the
                        "${PROJECT_SOURCE_DIR}/resources/cmake/pkg_config.pc.in") # This line must not touch the

  MESSAGE(STATUS "Created pkg-config file: nd-view.pc")

  REGISTER_NEW_TARGET("nd-view")
  MESSAGE(STATUS "Created nd-view target")

  IF(NOT DEBUG_MODE)
    #
    # Install settings
    #
    # Header files -> ${PROJECT_INCLUDE_DIR_INSTALL_PATH}/nd-view
    # Libraries    -> ${PROJECT_LIBRARIES_INSTALL_PATH}/
    #
    INSTALL( TARGETS nd-view
            DESTINATION ${PROJECT_LIBRARIES_INSTALL_PATH}/
            PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
                        GROUP_READ             GROUP_EXECUTE
                        WORLD_READ             WORLD_EXECUTE
    )
    MESSAGE(STATUS "Generated install commands for nd-view library")

    INSTALL(  DIRECTORY  ${PROJECT_SOURCE_DIR}/nd-view/
              DESTINATION ${PROJECT_INCLUDE_DIR_INSTALL_PATH}/nd-view/
              FILE_PERMISSIONS      OWNER_READ OWNER_WRITE GROUP_READ
                                                            WORLD_READ
              DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
                                    GROUP_READ             GROUP_EXECUTE
                                    WORLD_READ             WORLD_EXECUTE
              FILES_MATCHING PATTERN "*.h" PATTERN "*.i"
    )
    MESSAGE(STATUS "Generated install commands for header files")
    INSTALL( FILES      "${PROJECT_SOURCE_DIR}/pkg-config/nd-view.pc"
            DESTINATION ${PROJECT_PKGCONFIG_INSTALL_PATH}
            PERMISSIONS OWNER_READ OWNER_WRITE
                        GROUP_READ
                        WORLD_READ
    )
    MESSAGE(STATUS "Generated install commands for nd-view.pc file")
    INSTALL( FILES      "${PROJECT_SOURCE_DIR}/resources/modules/FindND_VIEW.cmake"
            DESTINATION ${CMAKE_ROOT}/Modules/
            PERMISSIONS OWNER_READ OWNER_WRITE
                        GROUP_READ
                        WORLD_READ
    )
    MESSAGE(STATUS "Generated install commands for FindND_VIEW CMake module")
  ENDIF(NOT DEBUG_MODE)


ENDIF(NOT ND_VIEW_TARGET_DEPENDENCIES)