mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Name the project AtlasMisc as the atlas Object is shared. Not working as of 04.06.2026: - Linking to wxWidgets find_package target - Terrain.obj : `error LNK2019: Verweis auf nicht aufgel├Âstes externes Symbol ""int const wxEVT_NULL" (?wxEVT_NULL@@3HB)" in Funktion ""void __cdecl dynamic initializer for 'private: static struct wxEventTableEntry const * const TerrainSidebar::sm_eventTableEntries''(void)" (??__E?sm_eventTableEntries@TerrainSidebar@@0QBUwxEventTableEntry@@B@@YAXXZ)".` Working: - Using find_package extra variables to find most of the windows ext. libs - excluding SDL2 and Boost, which use the custom find_prebuild_library function
35 lines
1.2 KiB
CMake
35 lines
1.2 KiB
CMake
# Adds a custom precompiled header. This header must be included in the code if not added with FORCE_INCLUDE
|
|
function(precompile_header _target _header _source)
|
|
set(single_args FORCE_INCLUDE)
|
|
cmake_parse_arguments(args "" "${single_args}" "" ${ARGN})
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
|
# Solution based opon https://www.dominikgrabiec.com/posts/2022/10/18/precompiled_header_snippet.html
|
|
target_compile_options(${_target}
|
|
PRIVATE
|
|
"/Yu${_header}"
|
|
)
|
|
set_source_files_properties(${_source}
|
|
PROPERTIES
|
|
COMPILE_OPTIONS "/Yc${_header}"
|
|
)
|
|
if(${args_FORCE_INCLUDE})
|
|
set_source_files_properties(${_source}
|
|
PROPERTIES
|
|
COMPILE_OPTIONS /FI${_header}
|
|
)
|
|
endif()
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU|AppleClang" OR CMAKE_C_COMPILER_ID MATCHES "Clang|GNU|AppleClang")
|
|
# Solution is based on internal cmake code
|
|
set_source_files_properties(${_source}
|
|
PROPERTIES
|
|
COMPILE_OPTIONS -Winvalid-pch -x ${_header}.gch
|
|
)
|
|
if(${args_FORCE_INCLUDE})
|
|
set_source_files_properties(${_source}
|
|
PROPERTIES
|
|
COMPILE_OPTIONS include ${_header}.gch
|
|
)
|
|
endif()
|
|
endif()
|
|
endfunction()
|