Refactor module compilation into separate library
This allows us to disable clang-tidy for this folder.
This commit is contained in:
parent
47ec1d49e7
commit
1cf3fed50f
2 changed files with 50 additions and 37 deletions
|
@ -1,16 +1,14 @@
|
|||
# store the specified sources list in the specified variable
|
||||
function(GetSources source_list store_in_var)
|
||||
file(STRINGS "../source_lists/${source_list}" sources)
|
||||
set(${store_in_var} ${sources} PARENT_SCOPE)
|
||||
file(STRINGS "${CMAKE_SOURCE_DIR}/source_lists/${source_list}" sources)
|
||||
foreach(source IN LISTS sources)
|
||||
list(APPEND loaded_sources "${CMAKE_SOURCE_DIR}/src/${source}")
|
||||
set(${store_in_var} ${loaded_sources} PARENT_SCOPE)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
if(ENABLE_MYSQL)
|
||||
execute_process(COMMAND mysql_config --cflags OUTPUT_VARIABLE MYSQL_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REGEX REPLACE "-I" "" MYSQL_CFLAGS "${MYSQL_CFLAGS}")
|
||||
string(REGEX REPLACE "-DNDEBUG" "" MYSQL_CFLAGS "${MYSQL_CFLAGS}")
|
||||
execute_process(COMMAND mysql_config --libs OUTPUT_VARIABLE MYSQL_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
add_subdirectory("modules/mariadbpp/")
|
||||
endif()
|
||||
# external git submodules
|
||||
add_subdirectory("modules")
|
||||
|
||||
## some includes ##
|
||||
include_directories(SYSTEM ${PANGOCAIRO_INCLUDE_DIRS})
|
||||
|
@ -79,32 +77,6 @@ GetSources("libwesnoth_widgets" wesnoth_widget-sources)
|
|||
GetSources("libwesnoth" wesnoth_game_sources)
|
||||
GetSources("libwesnoth_core" wesnoth_core_sources)
|
||||
GetSources("wesnoth" wesnoth_sources)
|
||||
if(NOT ENABLE_SYSTEM_LUA)
|
||||
GetSources("lua" lua_sources)
|
||||
|
||||
# Inject a header into the Lua sources for Wesnoth-specific changes
|
||||
# makedepend won't see it so we have to specifically add it as a dependency.
|
||||
file(GLOB wesnoth_lua_config wesnoth_lua_config.h)
|
||||
set_source_files_properties(${lua_sources} PROPERTIES OBJECT_DEPENDS ${wesnoth_lua_config})
|
||||
|
||||
set_source_files_properties(${lua_sources} PROPERTIES LANGUAGE CXX)
|
||||
|
||||
# We explicitly want lua compiled as C++ version
|
||||
if(MSVC)
|
||||
set_source_files_properties(${lua_sources} PROPERTIES COMPILE_FLAGS "/FI\"${wesnoth_lua_config}\"")
|
||||
# silence an implicit bitshift conversion warning
|
||||
set_property(SOURCE SOURCE ${lua_sources} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4334 /TP")
|
||||
else()
|
||||
set_source_files_properties(${lua_sources} PROPERTIES COMPILE_FLAGS "-include \"${wesnoth_lua_config}\" -x c++ -Wno-old-style-cast -Wno-useless-cast -Wno-stringop-overflow")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# silence a Clang specific warning due to extra parenthesis in if statements
|
||||
set_property(SOURCE SOURCE ${lua_sources} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-parentheses-equality")
|
||||
# silence a Clang specific warning when compiling the lua code
|
||||
set_property(SOURCE SOURCE ${lua_sources} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-string-plus-int")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(wesnoth_core_sources ${wesnoth_core_sources} log_windows.cpp)
|
||||
|
@ -211,8 +183,10 @@ endif()
|
|||
|
||||
add_library(wesnoth-common STATIC ${wesnoth_core_sources})
|
||||
if(ENABLE_GAME OR ENABLE_TESTS)
|
||||
add_library(wesnoth-client STATIC ${wesnoth_sources} ${lua_sources} ${wesnoth_game_sources} ${wesnoth_sdl_sources})
|
||||
|
||||
add_library(wesnoth-client STATIC ${wesnoth_sources} ${wesnoth_game_sources} ${wesnoth_sdl_sources})
|
||||
if(NOT ENABLE_SYSTEM_LUA)
|
||||
target_link_libraries(wesnoth-client lua)
|
||||
endif()
|
||||
# widgets need special handling since otherwise the way they're registered causes the linker to remove them since it incorrectly thinks they're unused
|
||||
add_library(wesnoth-widgets STATIC ${wesnoth_widget-sources})
|
||||
if(APPLE)
|
||||
|
|
39
src/modules/CMakeLists.txt
Normal file
39
src/modules/CMakeLists.txt
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Disable clang-tidy for all git submodules, since we can't fix these issues
|
||||
# in the wesnoth repo
|
||||
set(CMAKE_CXX_CLANG_TIDY "")
|
||||
if(ENABLE_MYSQL)
|
||||
execute_process(COMMAND mysql_config --cflags OUTPUT_VARIABLE MYSQL_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REGEX REPLACE "-I" "" MYSQL_CFLAGS "${MYSQL_CFLAGS}")
|
||||
string(REGEX REPLACE "-DNDEBUG" "" MYSQL_CFLAGS "${MYSQL_CFLAGS}")
|
||||
execute_process(COMMAND mysql_config --libs OUTPUT_VARIABLE MYSQL_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
add_subdirectory("mariadbpp/")
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_SYSTEM_LUA)
|
||||
GetSources("lua" lua_sources)
|
||||
|
||||
# Inject a header into the Lua sources for Wesnoth-specific changes
|
||||
# makedepend won't see it so we have to specifically add it as a dependency.
|
||||
file(GLOB wesnoth_lua_config ../wesnoth_lua_config.h)
|
||||
set_source_files_properties(${lua_sources} PROPERTIES OBJECT_DEPENDS ${wesnoth_lua_config})
|
||||
|
||||
set_source_files_properties(${lua_sources} PROPERTIES LANGUAGE CXX)
|
||||
|
||||
# We explicitly want lua compiled as C++ version
|
||||
if(MSVC)
|
||||
set_source_files_properties(${lua_sources} PROPERTIES COMPILE_FLAGS "/FI\"${wesnoth_lua_config}\"")
|
||||
# silence an implicit bitshift conversion warning
|
||||
set_property(SOURCE SOURCE ${lua_sources} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4334 /TP")
|
||||
else()
|
||||
set_source_files_properties(${lua_sources} PROPERTIES COMPILE_FLAGS "-include \"${wesnoth_lua_config}\" -x c++ -Wno-old-style-cast -Wno-useless-cast -Wno-stringop-overflow")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# silence a Clang specific warning due to extra parenthesis in if statements
|
||||
set_property(SOURCE SOURCE ${lua_sources} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-parentheses-equality")
|
||||
# silence a Clang specific warning when compiling the lua code
|
||||
set_property(SOURCE SOURCE ${lua_sources} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-string-plus-int")
|
||||
endif()
|
||||
|
||||
add_library(lua STATIC ${lua_sources})
|
||||
endif()
|
Loading…
Add table
Reference in a new issue