[89] | 1 | #################################################
|
---|
| 2 | # ___________ ____ ______ __ __ _____ #
|
---|
| 3 | # \____ \__ \ _/ ___\\____ \| | \/ ___/ #
|
---|
| 4 | # | |_> > __ \\ \___| |_> > | /\___ \ #
|
---|
| 5 | # | __(____ /\___ > __/|____//____ > #
|
---|
| 6 | # |__| \/ \/|__| \/ #
|
---|
| 7 | # #
|
---|
| 8 | #################################################
|
---|
| 9 |
|
---|
| 10 | project(Pacpus)
|
---|
| 11 | cmake_minimum_required(VERSION 2.8)
|
---|
[124] | 12 |
|
---|
[128] | 13 | if(POLICY CMP0020)
|
---|
[185] | 14 | cmake_policy(SET CMP0020 NEW) # for QT5.1 on windows / not work on linux
|
---|
[128] | 15 | endif()
|
---|
[322] | 16 | if(POLICY CMP0026)
|
---|
| 17 | # allow using LOCATION_DEBUG in cmake/PacpusUtilities.cmake
|
---|
| 18 | cmake_policy(SET CMP0026 OLD)
|
---|
| 19 | endif()
|
---|
[124] | 20 |
|
---|
[185] | 21 | ################################################################################
|
---|
[89] | 22 | # Pacpus version
|
---|
[185] | 23 | set(${PROJECT_NAME}_MAJOR_VERSION 0)
|
---|
[354] | 24 | set(${PROJECT_NAME}_MINOR_VERSION 3)
|
---|
[185] | 25 | set(${PROJECT_NAME}_PATCH_VERSION 0)
|
---|
| 26 | set(${PROJECT_NAME}_VERSION
|
---|
| 27 | "${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}")
|
---|
[89] | 28 |
|
---|
[185] | 29 | ################################################################################
|
---|
[89] | 30 | # CMake variables
|
---|
| 31 | set(PACPUS_ROOT_DIR ${CMAKE_SOURCE_DIR})
|
---|
| 32 | set(PACPUS_3RD_PARTY_DIR ${PACPUS_ROOT_DIR}/3rd)
|
---|
| 33 | set(PACPUS_CMAKE_DIR ${PACPUS_ROOT_DIR}/cmake)
|
---|
| 34 | set(PACPUS_DOC_DIR ${PACPUS_ROOT_DIR}/doc)
|
---|
[185] | 35 | set(PACPUS_EXAMPLES_DIR ${PACPUS_ROOT_DIR}/examples)
|
---|
[187] | 36 | set(PACPUS_INCLUDE_DIR ${PACPUS_ROOT_DIR}/include)
|
---|
[89] | 37 | set(PACPUS_SCRIPTS_DIR ${PACPUS_ROOT_DIR}/scripts)
|
---|
| 38 | set(PACPUS_SOURCE_DIR ${PACPUS_ROOT_DIR}/src)
|
---|
[301] | 39 | set(PACPUS_TEST_DIR ${PACPUS_ROOT_DIR}/test)
|
---|
[89] | 40 | set(IS_BUILDING_PACPUS TRUE)
|
---|
| 41 |
|
---|
[236] | 42 | set(PACPUS_DEFINITIONS "")
|
---|
| 43 |
|
---|
[185] | 44 | ################################################################################
|
---|
[301] | 45 | set(PACPUS_BUILD_TESTS TRUE CACHE BOOL "Whether build the tests")
|
---|
| 46 |
|
---|
| 47 | ################################################################################
|
---|
[89] | 48 | # Configure CMake
|
---|
| 49 | list(APPEND CMAKE_MODULE_PATH ${PACPUS_CMAKE_DIR})
|
---|
| 50 |
|
---|
[185] | 51 | ################################################################################
|
---|
[89] | 52 | # Import some functions
|
---|
| 53 | include(${PACPUS_CMAKE_DIR}/PacpusUtilities.cmake)
|
---|
| 54 |
|
---|
[185] | 55 | ################################################################################
|
---|
[89] | 56 | # Configure Pacpus
|
---|
| 57 | include(${PACPUS_CMAKE_DIR}/PacpusConfiguration.cmake)
|
---|
| 58 |
|
---|
[185] | 59 | ################################################################################
|
---|
[89] | 60 | # Find dependencies
|
---|
| 61 | include(${PACPUS_CMAKE_DIR}/PacpusDependencies.cmake)
|
---|
| 62 |
|
---|
[185] | 63 | ################################################################################
|
---|
[140] | 64 | # Handle platform-specific behaviour
|
---|
[89] | 65 | include(${PACPUS_CMAKE_DIR}/PacpusPlatforms.cmake)
|
---|
| 66 |
|
---|
[185] | 67 | ################################################################################
|
---|
[140] | 68 | # Compiler flags coming from PacpusDependencies and PacpusPlatforms
|
---|
[239] | 69 | message(STATUS "\${PACPUS_DEFINITIONS} = ${PACPUS_DEFINITIONS}")
|
---|
| 70 | message(STATUS "\${PACPUS_DEPENDENCIES_INC} = ${PACPUS_DEPENDENCIES_INC}")
|
---|
| 71 | message(STATUS "\${PACPUS_DEPENDENCIES_LIB} = ${PACPUS_DEPENDENCIES_LIB}")
|
---|
[140] | 72 | add_definitions(${PACPUS_DEFINITIONS})
|
---|
| 73 |
|
---|
[185] | 74 | ################################################################################
|
---|
[89] | 75 | # Includes directories
|
---|
| 76 | include_directories(
|
---|
[140] | 77 | ${PACPUS_DEPENDENCIES_INC}
|
---|
| 78 | ${PACPUS_INCLUDE_DIR}
|
---|
[89] | 79 | )
|
---|
| 80 |
|
---|
[185] | 81 | ################################################################################
|
---|
[89] | 82 | # Build the Pacpus' modules
|
---|
| 83 | add_subdirectory(${PACPUS_SOURCE_DIR})
|
---|
| 84 |
|
---|
[185] | 85 | ################################################################################
|
---|
| 86 | # DOCUMENTATION
|
---|
[89] | 87 | if(PACPUS_BUILD_DOC)
|
---|
| 88 | add_subdirectory(${PACPUS_DOC_DIR})
|
---|
| 89 | endif()
|
---|
| 90 |
|
---|
[185] | 91 | ################################################################################
|
---|
[89] | 92 | # Pacpus Installation
|
---|
| 93 | include(${PACPUS_CMAKE_DIR}/PacpusInstall.cmake)
|
---|
[175] | 94 | set(ENV{PACPUS_ROOT} ${PACPUS_INSTALL_DIR})
|
---|
[89] | 95 |
|
---|
[185] | 96 | ################################################################################
|
---|
| 97 | # EXAMPLES
|
---|
| 98 | if(PACPUS_BUILD_EXAMPLES)
|
---|
| 99 | add_subdirectory(${PACPUS_EXAMPLES_DIR})
|
---|
| 100 | endif()
|
---|
| 101 |
|
---|
| 102 | ################################################################################
|
---|
[301] | 103 | # TESTS
|
---|
| 104 | if(${PACPUS_BUILD_TESTS})
|
---|
| 105 | enable_testing()
|
---|
| 106 | #add_subdirectory(${PACPUS_TEST_DIR})
|
---|
| 107 | endif()
|
---|
| 108 |
|
---|
| 109 | ################################################################################
|
---|
[185] | 110 | # SUMMARY
|
---|
[89] | 111 | pacpus_info("")
|
---|
| 112 | pacpus_info("=====================================================================")
|
---|
[185] | 113 | pacpus_info("Configuration for Pacpus ${${PROJECT_NAME}_VERSION}")
|
---|
[89] | 114 | pacpus_info("=====================================================================")
|
---|
| 115 | pacpus_info("")
|
---|
| 116 | pacpus_info(" Platform:")
|
---|
| 117 | pacpus_info(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
---|
| 118 | if(CMAKE_CROSS_COMPILING)
|
---|
| 119 | pacpus_info(" Target:" ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR})
|
---|
| 120 | endif()
|
---|
| 121 | pacpus_info(" CMake:" ${CMAKE_VERSION})
|
---|
| 122 | pacpus_info(" CMake generator:" ${CMAKE_GENERATOR})
|
---|
| 123 | pacpus_info(" CMake build tool:" ${CMAKE_BUILD_TOOL})
|
---|
| 124 | if(MSVC)
|
---|
| 125 | pacpus_info(" MSVC:" ${MSVC_VERSION})
|
---|
| 126 | else()
|
---|
| 127 | pacpus_info(" Configuration:" ${CMAKE_BUILD_TYPE})
|
---|
| 128 | endif()
|
---|
| 129 | pacpus_info("")
|
---|
| 130 | pacpus_info(" Compiler:")
|
---|
| 131 | pacpus_info(" C++ Compiler:" ${CMAKE_CXX_COMPILER})
|
---|
| 132 | pacpus_info(" C++ flags (release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
|
---|
| 133 | pacpus_info(" C++ flags (debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
|
---|
| 134 | pacpus_info("")
|
---|
| 135 | pacpus_info(" Result:")
|
---|
| 136 | pacpus_info(" Install directory:" ${PACPUS_INSTALL_DIR})
|
---|
[162] | 137 | pacpus_info(" Install with version number:" ${PACPUS_INSTALL_WITH_VERSION_NUMBER})
|
---|
[89] | 138 | pacpus_info("")
|
---|
| 139 | pacpus_info(" Options:")
|
---|
| 140 | pacpus_info(" Logging enabled:" ${PACPUS_USE_LOG})
|
---|
[239] | 141 | pacpus_info(" Colored logging enabled:" ${PACPUS_LOG_COLORED_OUTPUT})
|
---|
[89] | 142 | pacpus_info(" Installation of 3rd party:" ${PACPUS_INSTALL_3RD})
|
---|
| 143 | pacpus_info(" Documentation enabled:" ${PACPUS_BUILD_DOC})
|
---|
| 144 | pacpus_info("")
|
---|
| 145 | if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
|
---|
[162] | 146 | message(WARNING "The source directory is the same as build directory. \"make clean\" may damage the source tree")
|
---|
[89] | 147 | endif()
|
---|