Minor cmake code review

This commit is contained in:
walbourn 2022-12-02 22:49:20 -08:00
parent 03f453758b
commit 1a1dda427f

View File

@ -39,7 +39,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
if (DEFINED VCPKG_TARGET_ARCHITECTURE)
if(DEFINED VCPKG_TARGET_ARCHITECTURE)
set(DIRECTX_ARCH ${VCPKG_TARGET_ARCHITECTURE})
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
set(DIRECTX_ARCH x86)
@ -122,11 +122,11 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
target_include_directories(${PROJECT_NAME} PRIVATE UVAtlas UVAtlas/geodesics UVAtlas/isochart)
if (NOT MINGW)
if(NOT MINGW)
target_precompile_headers(${PROJECT_NAME} PRIVATE UVAtlas/pch.h)
endif()
if (MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN)
if(MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN)
message("INFO: Using VCPKG for DirectX-Headers and DirectXMath.")
find_package(directx-headers CONFIG REQUIRED)
find_package(directxmath CONFIG REQUIRED)
@ -134,7 +134,7 @@ if (MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN)
target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS)
endif()
if (ENABLE_USE_EIGEN)
if(ENABLE_USE_EIGEN)
message("INFO: Using Eigen3 & Spectra for CSymmetricMatrix::GetEigen.")
find_package(Eigen3 REQUIRED)
find_package(spectra REQUIRED)
@ -198,7 +198,7 @@ if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE))
Microsoft::DirectXMesh::Utilities)
source_group(uvatlastool REGULAR_EXPRESSION UVAtlasTool/*.*)
if (MINGW OR VCPKG_TOOLCHAIN)
if(MINGW OR VCPKG_TOOLCHAIN)
target_link_libraries(uvatlastool Microsoft::DirectXMath)
endif()
endif()
@ -222,10 +222,14 @@ if(MSVC)
target_link_options(${t} PRIVATE "$<$<NOT:$<CONFIG:DEBUG>>:/guard:ehcont>")
endforeach()
endif()
else()
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_definitions(${t} PRIVATE $<IF:$<CONFIG:DEBUG>,_DEBUG,NDEBUG>)
endforeach()
endif()
if(NOT (${DIRECTX_ARCH} MATCHES "^arm"))
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4")
if(${CMAKE_SIZEOF_VOID_P} EQUAL "4")
set(ARCH_SSE2 $<$<CXX_COMPILER_ID:MSVC>:/arch:SSE2> $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse2>)
else()
set(ARCH_SSE2 $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse2>)
@ -236,7 +240,7 @@ if(NOT (${DIRECTX_ARCH} MATCHES "^arm"))
endforeach()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WarningsLib -Wall -Wpedantic -Wextra)
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
@ -246,11 +250,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endforeach()
elseif(MINGW)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_definitions(${t} PRIVATE $<IF:$<CONFIG:DEBUG>,_DEBUG,NDEBUG>)
target_compile_options(${t} PRIVATE "-Wno-ignored-attributes")
target_link_options(${t} PRIVATE -municode)
endforeach()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus)
endforeach()
@ -261,19 +264,19 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
endforeach()
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /ZH:SHA_256)
endforeach()
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /Zc:preprocessor /wd5105)
endforeach()
endif()
if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) AND (NOT (${DIRECTX_ARCH} MATCHES "^arm")))
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) AND (NOT (${DIRECTX_ARCH} MATCHES "^arm")))
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_link_options(${t} PRIVATE /CETCOMPAT)
endforeach()
@ -286,7 +289,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
endif()
set(WarningsEXE "/wd4365" "/wd4514" "/wd4625" "/wd4626" "/wd4627" "/wd4668" "/wd4710" "/wd4751" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd4061" "/wd4062" "/wd5219")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.34)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.34)
list(APPEND WarningsEXE "/wd5262" "/wd5264")
target_compile_options(${PROJECT_NAME} PRIVATE "/wd5262")
endif()