Improved CMake structure.

This commit is contained in:
Patrick Lühne 2017-05-09 13:01:10 +02:00
parent 9c9995380e
commit 88cb8f4516
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
4 changed files with 20 additions and 6 deletions

View File

@ -16,6 +16,14 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if (CMAKE_GENERATOR STREQUAL "Ninja" AND
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)))
# Force colored warnings in Ninja's output, if the compiler has -fdiagnostics-color support.
# Rationale in https://github.com/ninja-build/ninja/issues/814
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(app) add_subdirectory(app)
if(PLASP_BUILD_TESTS) if(PLASP_BUILD_TESTS)

View File

@ -3,7 +3,7 @@ set(target plasp-app)
file(GLOB core_sources "*.cpp") file(GLOB core_sources "*.cpp")
file(GLOB core_headers "*.h") file(GLOB core_headers "*.h")
include_directories( set(includes
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
) )
@ -19,5 +19,6 @@ set(libraries
) )
add_executable(${target} ${sources}) add_executable(${target} ${sources})
target_include_directories(${target} PRIVATE ${includes})
target_link_libraries(${target} ${libraries}) target_link_libraries(${target} ${libraries})
set_target_properties(${target} PROPERTIES OUTPUT_NAME plasp) set_target_properties(${target} PROPERTIES OUTPUT_NAME plasp)

View File

@ -21,11 +21,11 @@ file(GLOB input_headers "../include/plasp/input/*.h")
file(GLOB output_sources "plasp/output/*.cpp") file(GLOB output_sources "plasp/output/*.cpp")
file(GLOB output_headers "../include/plasp/output/*.h") file(GLOB output_headers "../include/plasp/output/*.h")
include_directories( file(GLOB utils_sources "plasp/utils/*.cpp")
${Boost_INCLUDE_DIRS} file(GLOB utils_headers "../include/plasp/utils/*.h")
)
include_directories( set(includes
${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
) )
@ -50,6 +50,9 @@ set(sources
${output_sources} ${output_sources}
${output_headers} ${output_headers}
${utils_sources}
${utils_headers}
) )
set(libraries set(libraries
@ -58,4 +61,5 @@ set(libraries
) )
add_library(${target} ${sources}) add_library(${target} ${sources})
target_include_directories(${target} PRIVATE ${includes})
target_link_libraries(${target} ${libraries}) target_link_libraries(${target} ${libraries})

View File

@ -2,7 +2,7 @@ set(target tests)
file(GLOB core_sources "*.cpp") file(GLOB core_sources "*.cpp")
include_directories( set(includes
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/lib/catch/single_include ${PROJECT_SOURCE_DIR}/lib/catch/single_include
@ -14,6 +14,7 @@ set(libraries
) )
add_executable(${target} ${core_sources}) add_executable(${target} ${core_sources})
target_include_directories(${target} PRIVATE ${includes})
target_link_libraries(${target} ${libraries}) target_link_libraries(${target} ${libraries})
add_custom_target(run-tests add_custom_target(run-tests