diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 106 |
1 files changed, 61 insertions, 45 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 49d207b9..7986654b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18 FATAL_ERROR) project(floormat) set(CMAKE_CXX_STANDARD 23) @@ -22,26 +22,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) set(CMAKE_INSTALL_MESSAGE LAZY) -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR CMAKE_INSTALL_PREFIX STREQUAL "") - set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "" FORCE) -endif() - -if(WIN32) - add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -DWIN32_LEAN_AND_MEAN) -endif() - -if(MSVC) - add_definitions(-D_USE_MATH_DEFINES=1) -endif() - -if(COMMAND fm_hook_pre_external) - fm_hook_pre_external() -endif() - -set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS OFF) -set_directory_properties(PROPERTIES CORRADE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) -set_directory_properties(PROPERTIES INTERFACE_CORRADE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) - function(sets type) set(i 0) list(LENGTH ARGN max) @@ -58,24 +38,11 @@ function(sets type) endwhile() endfunction() -cmake_policy(SET CMP0063 NEW) - -if(MSVC) - add_compile_options(-permissive-) - add_compile_options( - -wd4244 # warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data - -wd4312 # warning C4312: 'reinterpret_cast': conversion from 'GLenum' to 'void *' of greater size - -wd4251 # warning C4251: 't::f': class 'x' needs to have dll-interface to be used by clients of class 'y' - -wd4456 # warning C4456: declaration of 'x' hides previous local declaration - ) - add_compile_options(-external:W0 -external:anglebrackets) - if(CMAKE_SIZEOF_VOID_P GREATER_EQUAL 8) - add_link_options(-HIGHENTROPYVA) +function(fm_run_hook str) + if(COMMAND "${str}") + cmake_language(CALL "${str}") endif() -endif() - -set(FLOORMAT_SUBMODULE_DEPENDENCIES ON CACHE BOOL - "Use dependencies included in the source directory (needs git submodule update --init).") +endfunction() function(fm_load_userconfig) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") @@ -85,17 +52,53 @@ function(fm_load_userconfig) endif() set(_fm_userconfig "userconfig-${_fm_username}@${CMAKE_CXX_COMPILER_ID}.cmake") if(EXISTS "${CMAKE_SOURCE_DIR}/${_fm_userconfig}") + message(STATUS "loading user config '${_fm_userconfig}'") include("${CMAKE_SOURCE_DIR}/${_fm_userconfig}") else() message(STATUS "user config '${_fm_userconfig}' not found") endif() endfunction() -fm_load_userconfig() -add_subdirectory(external) +if(NOT "$ENV{FLOORMAT_NO_USERCONFIG}" AND NOT FLOORMAT_NO_USERCONFIG) + fm_load_userconfig() +endif() -include_directories(.) -include_directories(src) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR CMAKE_INSTALL_PREFIX STREQUAL "") + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "" FORCE) +endif() + +if(WIN32) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -DWIN32_LEAN_AND_MEAN) +endif() + +if(MSVC) + add_definitions(-D_USE_MATH_DEFINES=1) + add_compile_options(-permissive-) + add_compile_options( + -wd4244 # warning C4244: 'argument': conversion from 'int' to 'float', possible loss of data + -wd4312 # warning C4312: 'reinterpret_cast': conversion from 'GLenum' to 'void *' of greater size + -wd4251 # warning C4251: 't::f': class 'x' needs to have dll-interface to be used by clients of class 'y' + -wd4456 # warning C4456: declaration of 'x' hides previous local declaration + ) + add_compile_options(-external:W0 -external:anglebrackets) + if(CMAKE_SIZEOF_VOID_P GREATER_EQUAL 8) + add_link_options(-HIGHENTROPYVA) + endif() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang$") + add_compile_options(-Wno-reserved-macro-identifier) +endif() + +cmake_policy(SET CMP0063 NEW) + +set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS OFF) +set_directory_properties(PROPERTIES CORRADE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) +set_directory_properties(PROPERTIES INTERFACE_CORRADE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) + +fm_run_hook(fm-userconfig-init) + +add_subdirectory(external) if(MSVC) add_definitions(/FI"compat/prelude.hpp") @@ -103,9 +106,19 @@ else() add_definitions(-include compat/prelude.hpp) endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang$") - set_property(DIRECTORY APPEND PROPERTY COMPILE_FLAGS -Wignored-attributes -Werror -ferror-limit=5) -endif() +fm_run_hook(fm-userconfig-src) + +include_directories(.) +include_directories(src) + +#get_property(_fm-sdl2-include-dirs TARGET SDL2::SDL2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +include_directories(SYSTEM + "${CORRADE_INCLUDE_DIR}" + "${MAGNUM_INCLUDE_DIR}" + "${MAGNUMPLUGINS_INCLUDE_DIR}" + "${MAGNUMINTEGRATION_INCLUDE_DIR}" + #${_fm-sdl2-include-dirs} +) add_subdirectory(src) add_subdirectory(draw) @@ -114,3 +127,6 @@ add_subdirectory(anim-crop-tool) add_subdirectory(test) install(DIRECTORY images DESTINATION "share/${PROJECT_NAME}") + +fm_run_hook(fm-userconfig-post) +get_cmake_property(_variableNames VARIABLES) |