Fix for incorrect compile flags in colobot-lint

master
Piotr Dziwinski 2015-07-19 18:11:12 +02:00
parent 9ec289203b
commit 73536290b2
4 changed files with 24 additions and 10 deletions

View File

@ -202,6 +202,10 @@ option(GLEW_STATIC "Link statically with GLEW" OFF)
# Sometimes helpful if there is a different version of gtest installed on system vs bundled
option(FORCE_BUNDLED_GTEST "Force the use of bundled gtest" OFF)
# This is for use with colobot-lint tool
option(COLOBOT_LINT_BUILD "Generate some additional CMake targets for use with colobot-lint" OFF)
# Default build type if not given is debug
if(NOT DEFINED CMAKE_BUILD_TYPE)
message(STATUS "Build type not specified - assuming debug")
@ -267,12 +271,12 @@ include("${colobot_SOURCE_DIR}/cmake/mxe.cmake")
##
include("${colobot_SOURCE_DIR}/cmake/msys.cmake")
##
# Additional settings for colobot-lint
# Additional functions for colobot-lint
##
include("${colobot_SOURCE_DIR}/cmake/colobot-lint.cmake")
##
# MSVC specific settings
##

View File

@ -1,15 +1,17 @@
# Some functions for use with colobot-lint
option(COLOBOT_LINT_BUILD "Enable some additional functions for use with colobot-lint")
if(COLOBOT_LINT_BUILD)
##
# This adds a new target with generated fake source files that include single header files
# It is a workaround for how CMake and Clang handle header files in compilation database
# And we need that to check each header file in the project exactly once, the same as .cpp modules
##
macro(add_fake_header_sources subdir)
set(all_fake_header_src_files "")
set(fake_headers_src_dir ${colobot_BINARY_DIR}/fake_header_sources)
file(MAKE_DIRECTORY ${fake_headers_src_dir})
file(GLOB_RECURSE all_header_files RELATIVE ${colobot_SOURCE_DIR} src/*.h test/*.h)
file(GLOB_RECURSE all_header_files RELATIVE ${colobot_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
foreach(header_file ${all_header_files})
string(REGEX REPLACE "\\.h$" ".cpp" fake_header_src_file "${fake_headers_src_dir}/${header_file}")
@ -23,6 +25,5 @@ if(COLOBOT_LINT_BUILD)
endforeach()
include_directories(${colobot_SOURCE_DIR})
add_library(colobot_fake_header_srcs STATIC ${all_fake_header_src_files})
endif()
add_library(colobot_${subdir}_fake_header_srcs STATIC ${all_fake_header_src_files})
endmacro()

View File

@ -306,3 +306,7 @@ install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
if(NOT CBOT_STATIC)
set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
endif()
if(COLOBOT_LINT_BUILD)
add_fake_header_sources("src")
endif()

View File

@ -11,3 +11,8 @@ add_subdirectory(unit)
# Test environments
add_subdirectory(envs)
if(COLOBOT_LINT_BUILD)
add_fake_header_sources("test")
endif()