diff --git a/CMakeLists.txt b/CMakeLists.txt index b2944dd7..e3f2a5be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,6 +268,11 @@ include("${colobot_SOURCE_DIR}/cmake/mxe.cmake") include("${colobot_SOURCE_DIR}/cmake/msys.cmake") +## +# Additional settings for colobot-lint +## +include("${colobot_SOURCE_DIR}/cmake/colobot-lint.cmake") + ## # MSVC specific settings ## diff --git a/cmake/colobot-lint.cmake b/cmake/colobot-lint.cmake new file mode 100644 index 00000000..7efa5cb3 --- /dev/null +++ b/cmake/colobot-lint.cmake @@ -0,0 +1,28 @@ +# Some functions for use with colobot-lint + +option(COLOBOT_LINT_BUILD "Enable some additional functions for use with colobot-lint") + +if(COLOBOT_LINT_BUILD) + + 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) + + foreach(header_file ${all_header_files}) + string(REGEX REPLACE "\\.h$" ".cpp" fake_header_src_file "${fake_headers_src_dir}/${header_file}") + + get_filename_component(fake_header_src_dir ${fake_header_src_file} PATH) + file(MAKE_DIRECTORY ${fake_header_src_dir}) + + file(WRITE ${fake_header_src_file} "#include \"${header_file}\"\n\n") + + list(APPEND all_fake_header_src_files ${fake_header_src_file}) + endforeach() + + include_directories(${colobot_SOURCE_DIR}) + add_library(colobot_fake_header_srcs STATIC ${all_fake_header_src_files}) + +endif()