CMakeLists.txt 2.76 KB
Newer Older
Hurstel's avatar
Hurstel 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
cmake_minimum_required (VERSION 3.1)


PROJECT(proto1_cpp)

#set( CMAKE_BUILD_TYPE Debug)

set ( CMAKE_VERBOSE_MAKEFILE true )

INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/functions.cmake)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/module_comp.cmake)
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)


checkCpp11Support()
setBuildType()

message("Build type:  ${CMAKE_BUILD_TYPE}")


IF ((${CMAKE_BUILD_TYPE} MATCHES "Debug"))
    SET(COMPILE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/debug" CACHE STRING "compile directory (empty for default)")

    SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/debug)
    SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libD)
ELSE ((${CMAKE_BUILD_TYPE} MATCHES "Debug"))
    SET(COMPILE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin" CACHE STRING "compile directory (empty for default)")

    SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
    SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)
ENDIF ((${CMAKE_BUILD_TYPE} MATCHES "Debug"))

# C++11
set (CMAKE_CXX_STANDARD 11)

SET(PYTHON_ENV_PATH "${COMPILE_DIRECTORY}" CACHE STRING "the default python working directory")
SET(DEV_PYTHON_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../py" CACHE STRING "the project's python modules directory" )

link_directories(${LIBRARY_OUTPUT_PATH})

SET(PY_LESS TRUE CACHE BOOL "Without python?")

IF(PY_LESS)
    find_package(Boost)
    add_definitions(-DNOPYTHON)
ELSE(PY_LESS)
    find_package(Boost EXACT REQUIRED COMPONENTS python3)
    find_package(PythonLibs)
ENDIF(PY_LESS)

SET(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
SET(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/includes)

SET(CORE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/core)

ADD_SUBDIRECTORY(${CORE_DIR})

SET(MODS "")
SET(MOD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/mods)
SET(MOD_DIRS "")
SET(COMPILE_MOD TRUE CACHE BOOL "Compile mods?")

IF(COMPILE_MOD)
    ADD_SUBDIRECTORY(${MOD_DIR})

    module_comp_gen("${MODS}" "${INCLUDE_DIR}/modules.h")
ENDIF(COMPILE_MOD)

INCLUDE_DIRECTORIES(${INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${MOD_DIR} ${MOD_DIRS} ${CORE_INCLUDE_DIR})

file(
    GLOB_RECURSE
    SOURCE_FILES
    ${SOURCE_DIR}/*.cpp
)

file(
    GLOB_RECURSE
    INCLUDE_FILES
    ${INCLUDE_DIR}/*.h
    ${INCLUDE_DIR}/*.hpp
)

IF( NOT PY_LESS )
    file(
        GLOB_RECURSE
        PY_FILES
        ${SOURCE_DIR}/*.py
    )
ENDIF( NOT PY_LESS )

link_directories(${LIBRARY_OUTPUT_PATH} ${Boost_LIBRARY_DIRS})

ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCE_FILES} ${INCLUDE_FILES} ${CORE_INCLUDE_FILES} ${MOD_DIR}/modLists.txt)

TARGET_LINK_LIBRARIES(${PROJECT_NAME} pthread ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${MODS} Core)

IF(COMPILE_MOD)
    ADD_DEPENDENCIES(${PROJECT_NAME} ${MODS} Core)
ELSE(COMPILE_MOD)
    ADD_DEPENDENCIES(${PROJECT_NAME} Core)
ENDIF(COMPILE_MOD)