CMakeLists.txt 7.79 KB
#=============================================================================
# CMakeLists.txt - Rules for coolbot-sns-bundle project.
#
# Generated by coolbot-bundle version 1.0.0
#=============================================================================
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.4)
PROJECT(coolbot-sns-bundle CXX C)

# Sets the policy CMP0017. More info: cmake --help-policy CMP0017
IF(POLICY CMP0017)
  IF(COMMAND CMAKE_POLICY)
    CMAKE_POLICY(SET CMP0017 NEW)
  ENDIF(COMMAND CMAKE_POLICY)
ENDIF(POLICY CMP0017)

#
# Options available
#
OPTION(CREATE_ENV_VAR "Set to ON to create environment variables" OFF)
OPTION(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
OPTION(DEBUG_MODE "Set to ON to activate the debug mode" ON)
OPTION(SHOW_DEBUG_INFO "Set to ON to show debug info" OFF)
OPTION(SHOW_WARNINGS "Set to ON to show the project warnings" OFF)
OPTION(BUILD_TEST "Set to ON to build tests" OFF)

#
# Sets CMAKE_MODULE_PATH for use FIND_PACKAGE() in local CMake directory.
#
# NOTE: In the modules directory(resources/modules) you can find the modules
# for the components, views,...
#
# These modules contain the necessary instructions for CMake find the necessary
# information related to this project. You must edit these files.
#
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources/cmake
                      ${CMAKE_CURRENT_SOURCE_DIR}/resources/modules
                      ${CMAKE_MODULE_PATH}
                      ${CMAKE_ROOT}/Modules)

#
# Include CMake files
#
# NOTE: In cmake_global_variables.cmake file, you can set all global variables
#       that you want. These variables are visible from the entire project.
#
INCLUDE(${PROJECT_SOURCE_DIR}/resources/cmake/toolkit.cmake)
INCLUDE(${PROJECT_SOURCE_DIR}/resources/cmake/check_dependencies.cmake)
INCLUDE(${PROJECT_SOURCE_DIR}/resources/cmake/uninstall_target.cmake)
INCLUDE(${PROJECT_SOURCE_DIR}/resources/cmake/cmake_global_variables.cmake)

#
# Initializes the list of targets. If you are in production mode, the list has install and uninstall target.
#
INIT_TARGETS_LIST()

IF(NOT DEBUG_MODE)
  REGISTER_NEW_TARGET("install")
  REGISTER_NEW_TARGET("uninstall")
ENDIF(NOT DEBUG_MODE)

#
# General project settings
#
IF( DEBUG_MODE )
  SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Development mode" FORCE)
  SET(PROJECT_INSTALL_PATH ${PROJECT_SOURCE_DIR})
ELSE( DEBUG_MODE )
  SET(CMAKE_BUILD_TYPE Release CACHE STRING "Production Mode" FORCE)
  SET(PROJECT_INSTALL_PATH ${CMAKE_INSTALL_PREFIX})
ENDIF( DEBUG_MODE )

SET(BIN_DIR   "${PROJECT_SOURCE_DIR}/bin")
SET(LIB_DIR   "${PROJECT_SOURCE_DIR}/lib")
SET(PKG_DIR   "${PROJECT_SOURCE_DIR}/pkg-config")
SET(TESTS_DIR "${PROJECT_SOURCE_DIR}/tests")

SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_DIR} CACHE PATH "Directory for executables")
IF(UNIX)
  SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_DIR} CACHE PATH "Directory for module libraries")
ELSE(UNIX)
  SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_DIR} CACHE PATH "Directory for static libraries")
ENDIF(UNIX)
SET(PKG_CONFIG_PATH_DIRECTORY ${PKG_DIR} CACHE PATH "Directory for pkg-config")

SET(PROJECT_BINARIES_INSTALL_PATH "${PROJECT_INSTALL_PATH}/bin")
SET(PROJECT_LIBRARIES_INSTALL_PATH "${PROJECT_INSTALL_PATH}/lib/coolbot-sns-bundle")
SET(PROJECT_PKGCONFIG_INSTALL_PATH "${PROJECT_INSTALL_PATH}/lib/pkgconfig")
SET(PROJECT_INCLUDE_DIR_INSTALL_PATH "${PROJECT_INSTALL_PATH}/include")

SET(BUNDLE_NAME "coolbot-sns-bundle")

IF(SHOW_WARNINGS)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  IF(NOT WIN32)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings")
  ENDIF(NOT WIN32)
ELSE(SHOW_WARNINGS)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
ENDIF(SHOW_WARNINGS)

GET_OPERATING_SYSTEM( OS )

#
# Sets the targets available.
#
# In the cmake_external_common_dependencies.cmake file you can specify the external
# common dependencies of the project.
#
# The cmake_targets.cmake file is found in resources/cmake directory. This file
# contains the targets available that are generated by the tool coolbot-bundle.
# You must review this file and make sure that the targets are in the desired
# order.
#
IF(PROJECT_DEPENDENCIES)
  INCLUDE(${PROJECT_SOURCE_DIR}/resources/cmake/cmake_external_common_dependencies.cmake)
  INCLUDE(${PROJECT_SOURCE_DIR}/resources/cmake/cmake_targets.cmake)
ENDIF(PROJECT_DEPENDENCIES)

#
# Creates environment variables.
#
# Variables:
#
# - PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PROJECT_SOURCE_DIR}/pkg-config/
#
IF(CREATE_ENV_VAR)
  MESSAGE(STATUS "Try create the environment variable: PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PROJECT_SOURCE_DIR}/pkg-config")
  IF(UNIX)
    CREATE_ENV_VARIABLE( "PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:${PROJECT_SOURCE_DIR}/pkg-config"
                         ENV_VARIABLE_RESULT )
  ELSE(UNIX)
    CREATE_ENV_VARIABLE( "PKG_CONFIG_PATH=${PROJECT_SOURCE_DIR}/pkg-config/" ENV_VARIABLE_RESULT )
  ENDIF(UNIX)

  IF(ENV_VARIABLE_RESULT)
    MESSAGE(STATUS "Try create the environment variable: done")
  ELSE(ENV_VARIABLE_RESULT)
    MESSAGE(STATUS "Try create the environment variable: failed")
  ENDIF(ENV_VARIABLE_RESULT)

ENDIF(CREATE_ENV_VAR)

#
# Displays global configuration settings
#
MESSAGE("\n----- Summary about coolbot-sns-bundle project -----\n")

MESSAGE("   * System processor: ${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE("   * Operating system: ${OS}")
IF( DEBUG_MODE )
  MESSAGE("   * Build type: Development mode")
ELSE( DEBUG_MODE )
  MESSAGE("   * Build type: Production Mode")
ENDIF( DEBUG_MODE )
MESSAGE("   * Binary directory: ${BIN_DIR}")
MESSAGE("   * Library directory: ${LIB_DIR}")
MESSAGE("   * Pkg directory: ${PKG_DIR}")
MESSAGE("   * Tests directory: ${TESTS_DIR}")
MESSAGE("   * Install path: ${PROJECT_INSTALL_PATH}")
MESSAGE("   * Options available:")
IF(CREATE_ENV_VAR)
  MESSAGE("     ** Creates environment variables")
ELSE(CREATE_ENV_VAR)
  MESSAGE("     ** Don't creates environment variables")
ENDIF(CREATE_ENV_VAR)
IF(BUILD_SHARED_LIBS)
  MESSAGE("     ** Build share libraries")
ELSE(BUILD_SHARED_LIBS)
  MESSAGE("     ** Build static libraries")
ENDIF(BUILD_SHARED_LIBS)
IF(SHOW_DEBUG_INFO)
  MESSAGE("     ** Display debug information")
ELSE(SHOW_DEBUG_INFO)
  MESSAGE("     ** Hide debug information")
ENDIF(SHOW_DEBUG_INFO)
IF(SHOW_WARNINGS)
  MESSAGE("     ** Display the C/C++ compiler warnings")
ELSE(SHOW_WARNINGS)
  MESSAGE("     ** Hide the C/C++ compiler warnings")
ENDIF(SHOW_WARNINGS)
IF(BUILD_TEST)
  MESSAGE("     ** Build tests")
ELSE(BUILD_TEST)
  MESSAGE("     ** Don't build tests")
ENDIF(BUILD_TEST)

SET(AVAILABLE TRUE)
GET_TARGETS_LIST( TARGETS_AVAILABLE AVAILABLE )
IF(TARGETS_AVAILABLE)
  MESSAGE("   * Targets available:")
  FOREACH(the_target ${TARGETS_AVAILABLE})
    MESSAGE("     ** ${the_target}")
  ENDFOREACH(the_target)
ENDIF(TARGETS_AVAILABLE)

SET(AVAILABLE FALSE)
GET_TARGETS_LIST( TARGETS_AVAILABLE AVAILABLE )
IF(TARGETS_AVAILABLE)
  MESSAGE("   * Targets not available:")
  FOREACH(the_target ${TARGETS_AVAILABLE})
    MESSAGE("     ** ${the_target}")
  ENDFOREACH(the_target)
ENDIF(TARGETS_AVAILABLE)

MESSAGE("\n----- Building and install/uninstall instructions -----\n")
IF( CREATE_ENV_VAR )
  IF( UNIX )
    IF( ${OS} MATCHES "Darwin" )
      MESSAGE("   $ source ~/.profile (restart the shell)")
    ELSE( ${OS} MATCHES "Darwin" )
      MESSAGE("   $ source ~/.bashrc (restart the shell)")
    ENDIF( ${OS} MATCHES "Darwin" )
  ELSE( UNIX )
    MESSAGE("   Restart the shell so that the changes are applied")
  ENDIF( UNIX )

  #
  # Set to OFF the variable so that the macro does not run more than once.
  #
  SET(CREATE_ENV_VAR CACHE BOOL OFF FORCE)

ENDIF( CREATE_ENV_VAR )
MESSAGE("   $ make -j n (n is the number of processes you want to launch)")
IF(NOT DEBUG_MODE)
  MESSAGE("   $ make install (you might need to have administrator permissions)")
  MESSAGE("   $ make uninstall (you might need to have administrator permissions)\n")
ENDIF(NOT DEBUG_MODE)
MESSAGE("\n   For more information, see the INSTALL file\n")