2021-02-27 10:03:04 +03:00
|
|
|
# Copyright (c) Microsoft Corporation.
|
2019-12-01 21:23:59 +03:00
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
2022-11-15 23:59:47 +03:00
|
|
|
cmake_minimum_required (VERSION 3.20)
|
2019-12-01 21:23:59 +03:00
|
|
|
|
2023-04-29 07:33:43 +03:00
|
|
|
set(UVATLAS_VERSION 1.8.5)
|
2020-12-19 02:35:28 +03:00
|
|
|
|
2023-04-28 03:03:53 +03:00
|
|
|
if(DEFINED XBOX_CONSOLE_TARGET)
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
|
|
|
endif()
|
|
|
|
|
2020-12-19 02:35:28 +03:00
|
|
|
project (UVAtlas
|
|
|
|
VERSION ${UVATLAS_VERSION}
|
|
|
|
DESCRIPTION "UVAtlas Isochart Atlas Library"
|
|
|
|
HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkID=512686"
|
|
|
|
LANGUAGES CXX)
|
2019-12-01 21:23:59 +03:00
|
|
|
|
2020-02-15 10:28:06 +03:00
|
|
|
# To build this tool, you need the DirectXTex (http://go.microsoft.com/fwlink/?LinkId=248926) and
|
2020-12-19 02:35:28 +03:00
|
|
|
# DirectXMesh (http://go.microsoft.com/fwlink/?LinkID=324981) cmake packages available.
|
|
|
|
#
|
|
|
|
# Use vcpkg and set the required CMAKE_TOOLCHAIN_FILE path to vcpkg.cmake
|
2020-02-15 10:28:06 +03:00
|
|
|
#
|
2020-12-19 02:35:28 +03:00
|
|
|
# -or-
|
2020-02-15 10:28:06 +03:00
|
|
|
#
|
2020-12-19 02:35:28 +03:00
|
|
|
# cmake install the individual packages and add the per-configuration variables for directxmesh_DIR and directxtex_DIR
|
|
|
|
#
|
|
|
|
# Note to support Windows 7, turn off BUILD_DX12 build options for both libraries.
|
|
|
|
option(BUILD_TOOLS "Build UVAtlasTool" OFF)
|
2019-12-14 04:18:02 +03:00
|
|
|
|
2020-02-10 20:44:45 +03:00
|
|
|
# Enable the use of OpenMP
|
|
|
|
option(UVATLAS_USE_OPENMP "Build with OpenMP support" ON)
|
|
|
|
|
2021-06-01 02:47:23 +03:00
|
|
|
# Enable use of the Eigen and BLAS libraries (https://eigen.tuxfamily.org/)
|
|
|
|
option(ENABLE_USE_EIGEN "Use the Eigen & BLAS libraries" OFF)
|
|
|
|
|
2022-12-08 05:09:41 +03:00
|
|
|
# https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
|
|
|
|
option(ENABLE_SPECTRE_MITIGATION "Build using /Qspectre for MSVC" OFF)
|
|
|
|
|
2023-01-02 22:26:58 +03:00
|
|
|
option(DISABLE_MSVC_ITERATOR_DEBUGGING "Disable iterator debugging in Debug configurations with the MSVC CRT" OFF)
|
|
|
|
|
2020-06-06 01:18:07 +03:00
|
|
|
option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF)
|
|
|
|
|
2022-05-06 00:57:10 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-12-01 21:23:59 +03:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2020-08-11 06:15:30 +03:00
|
|
|
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")
|
2019-12-01 21:23:59 +03:00
|
|
|
|
2022-12-03 09:49:20 +03:00
|
|
|
if(DEFINED VCPKG_TARGET_ARCHITECTURE)
|
2022-03-19 11:07:51 +03:00
|
|
|
set(DIRECTX_ARCH ${VCPKG_TARGET_ARCHITECTURE})
|
2022-03-24 03:44:08 +03:00
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$")
|
|
|
|
set(DIRECTX_ARCH x86)
|
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$")
|
|
|
|
set(DIRECTX_ARCH x64)
|
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$")
|
|
|
|
set(DIRECTX_ARCH arm)
|
|
|
|
elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$")
|
|
|
|
set(DIRECTX_ARCH arm64)
|
2022-03-19 11:07:51 +03:00
|
|
|
endif()
|
|
|
|
|
2023-03-18 01:47:13 +03:00
|
|
|
if(WINDOWS_STORE OR (DEFINED XBOX_CONSOLE_TARGET))
|
2023-02-16 09:06:56 +03:00
|
|
|
set(BUILD_TOOLS OFF)
|
|
|
|
endif()
|
|
|
|
|
2022-05-02 13:02:28 +03:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2020-12-19 02:35:28 +03:00
|
|
|
#--- Library
|
|
|
|
set(LIBRARY_HEADERS
|
|
|
|
UVAtlas/inc/UVAtlas.h)
|
|
|
|
|
|
|
|
set(LIBRARY_SOURCES
|
2019-12-01 21:23:59 +03:00
|
|
|
UVAtlas/maxheap.hpp
|
|
|
|
UVAtlas/pch.h
|
|
|
|
UVAtlas/geodesics/ApproximateOneToAll.cpp
|
|
|
|
UVAtlas/geodesics/ApproximateOneToAll.h
|
|
|
|
UVAtlas/geodesics/datatypes.h
|
|
|
|
UVAtlas/geodesics/ExactOneToAll.cpp
|
|
|
|
UVAtlas/geodesics/ExactOneToAll.h
|
|
|
|
UVAtlas/geodesics/mathutils.cpp
|
|
|
|
UVAtlas/geodesics/mathutils.h
|
|
|
|
UVAtlas/geodesics/minheap.hpp
|
|
|
|
UVAtlas/isochart/barycentricparam.cpp
|
|
|
|
UVAtlas/isochart/basemeshinfo.cpp
|
|
|
|
UVAtlas/isochart/basemeshinfo.h
|
|
|
|
UVAtlas/isochart/callbackschemer.h
|
|
|
|
UVAtlas/isochart/graphcut.cpp
|
|
|
|
UVAtlas/isochart/graphcut.h
|
|
|
|
UVAtlas/isochart/imtcomputation.cpp
|
|
|
|
UVAtlas/isochart/isochart.cpp
|
|
|
|
UVAtlas/isochart/isochart.h
|
|
|
|
UVAtlas/isochart/isochartconfig.h
|
|
|
|
UVAtlas/isochart/isochartengine.cpp
|
|
|
|
UVAtlas/isochart/isochartengine.h
|
|
|
|
UVAtlas/isochart/isochartmesh.cpp
|
|
|
|
UVAtlas/isochart/isochartmesh.h
|
|
|
|
UVAtlas/isochart/isochartutil.cpp
|
|
|
|
UVAtlas/isochart/isochartutil.h
|
|
|
|
UVAtlas/isochart/isomap.cpp
|
|
|
|
UVAtlas/isochart/isomap.h
|
|
|
|
UVAtlas/isochart/lscmparam.cpp
|
|
|
|
UVAtlas/isochart/mergecharts.cpp
|
|
|
|
UVAtlas/isochart/meshapplyisomap.cpp
|
|
|
|
UVAtlas/isochart/meshcommon.inl
|
|
|
|
UVAtlas/isochart/meshoptimizeboundaries.cpp
|
|
|
|
UVAtlas/isochart/meshoptimizestretch.cpp
|
|
|
|
UVAtlas/isochart/meshpartitionchart.cpp
|
|
|
|
UVAtlas/isochart/packingcharts.cpp
|
|
|
|
UVAtlas/isochart/progressivemesh.cpp
|
|
|
|
UVAtlas/isochart/progressivemesh.h
|
|
|
|
UVAtlas/isochart/sparsematrix.hpp
|
|
|
|
UVAtlas/isochart/SymmetricMatrix.hpp
|
|
|
|
UVAtlas/isochart/UVAtlas.cpp
|
|
|
|
UVAtlas/isochart/UVAtlasRepacker.cpp
|
|
|
|
UVAtlas/isochart/UVAtlasRepacker.h
|
|
|
|
UVAtlas/isochart/vertiter.cpp
|
|
|
|
UVAtlas/isochart/vertiter.h
|
|
|
|
UVAtlas/isochart/Vis_Maxflow.cpp
|
|
|
|
UVAtlas/isochart/Vis_Maxflow.h
|
|
|
|
)
|
|
|
|
|
2020-12-19 02:35:28 +03:00
|
|
|
add_library (${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
|
2020-03-29 22:54:48 +03:00
|
|
|
|
2019-12-01 21:23:59 +03:00
|
|
|
source_group(inc REGULAR_EXPRESSION UVAtlas/inc/*.*)
|
|
|
|
source_group(geodesics REGULAR_EXPRESSION UVAtlas/geodesics/*.*)
|
|
|
|
source_group(isochart REGULAR_EXPRESSION UVAtlas/isochart/*.*)
|
|
|
|
source_group(isochart REGULAR_EXPRESSION UVAtlas/isochart/*.*)
|
|
|
|
|
2020-12-19 02:35:28 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/UVAtlas/inc>
|
2022-05-02 13:02:28 +03:00
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
2020-12-19 02:35:28 +03:00
|
|
|
|
2022-05-28 03:19:30 +03:00
|
|
|
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
|
|
|
|
|
2023-05-01 20:41:59 +03:00
|
|
|
if(UVATLAS_USE_OPENMP)
|
|
|
|
find_package(OpenMP)
|
|
|
|
if(OpenMP_CXX_FOUND)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC OpenMP::OpenMP_CXX)
|
|
|
|
else()
|
|
|
|
set(UVATLAS_USE_OPENMP OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-12-02 02:33:48 +03:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE UVAtlas UVAtlas/geodesics UVAtlas/isochart)
|
2019-12-01 21:23:59 +03:00
|
|
|
|
2022-12-03 09:49:20 +03:00
|
|
|
if(NOT MINGW)
|
2020-12-19 02:35:28 +03:00
|
|
|
target_precompile_headers(${PROJECT_NAME} PRIVATE UVAtlas/pch.h)
|
|
|
|
endif()
|
|
|
|
|
2023-02-10 05:54:37 +03:00
|
|
|
if(MINGW OR (NOT WIN32))
|
2021-01-08 13:02:15 +03:00
|
|
|
find_package(directxmath CONFIG REQUIRED)
|
2023-02-10 05:54:37 +03:00
|
|
|
find_package(directx-headers CONFIG REQUIRED)
|
|
|
|
else()
|
|
|
|
find_package(directxmath CONFIG QUIET)
|
|
|
|
find_package(directx-headers CONFIG QUIET)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(directxmath_FOUND)
|
|
|
|
message(STATUS "Using DirectXMath package")
|
2023-02-07 02:27:26 +03:00
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectXMath)
|
2023-02-10 05:54:37 +03:00
|
|
|
endif()
|
2023-02-07 02:27:26 +03:00
|
|
|
|
2023-02-10 05:54:37 +03:00
|
|
|
if(directx-headers_FOUND)
|
|
|
|
message(STATUS "Using DirectX-Headers package")
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Microsoft::DirectX-Headers)
|
2023-02-16 09:06:56 +03:00
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC USING_DIRECTX_HEADERS)
|
2021-01-08 13:02:15 +03:00
|
|
|
endif()
|
|
|
|
|
2022-12-03 09:49:20 +03:00
|
|
|
if(ENABLE_USE_EIGEN)
|
2022-12-08 05:09:41 +03:00
|
|
|
message(STATUS "Using Eigen3 & Spectra for CSymmetricMatrix::GetEigen.")
|
2021-06-12 11:49:26 +03:00
|
|
|
find_package(Eigen3 REQUIRED)
|
|
|
|
find_package(spectra REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE Eigen3::Eigen Spectra::Spectra)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PRIVATE UVATLAS_USE_EIGEN)
|
2021-06-01 02:47:23 +03:00
|
|
|
endif()
|
|
|
|
|
2023-02-16 09:06:56 +03:00
|
|
|
include(CheckIncludeFileCXX)
|
|
|
|
|
|
|
|
if(DEFINED XBOX_CONSOLE_TARGET)
|
|
|
|
message(STATUS "Building for Xbox Console Target: ${XBOX_CONSOLE_TARGET}")
|
|
|
|
set(CMAKE_REQUIRED_QUIET ON)
|
|
|
|
CHECK_INCLUDE_FILE_CXX(gxdk.h GXDK_HEADER)
|
|
|
|
if(NOT GXDK_HEADER)
|
|
|
|
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions required to build for Xbox. See https://aka.ms/gdkx")
|
|
|
|
endif()
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC WINAPI_FAMILY=WINAPI_FAMILY_GAMES)
|
|
|
|
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
|
|
|
CHECK_INCLUDE_FILE_CXX(d3d12_xs.h D3D12XS_HEADER)
|
|
|
|
if(NOT D3D12XS_HEADER)
|
|
|
|
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions environment needs to be set for Xbox Series X|S.")
|
|
|
|
endif()
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_SCARLETT)
|
|
|
|
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
|
|
|
CHECK_INCLUDE_FILE_CXX(d3d12_x.h D3D12X_HEADER)
|
|
|
|
if(NOT D3D12X_HEADER)
|
|
|
|
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions environment needs to be set for Xbox One.")
|
|
|
|
endif()
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_XBOXONE)
|
2023-04-28 03:03:53 +03:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unknown XBOX_CONSOLE_TARGET")
|
2023-02-16 09:06:56 +03:00
|
|
|
endif()
|
2023-04-28 03:03:53 +03:00
|
|
|
elseif(WINDOWS_STORE)
|
|
|
|
target_compile_definitions(${PROJECT_NAME} PUBLIC WINAPI_FAMILY=WINAPI_FAMILY_APP)
|
2023-02-16 09:06:56 +03:00
|
|
|
endif()
|
|
|
|
|
2020-12-19 02:35:28 +03:00
|
|
|
#--- Package
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
2020-12-29 13:52:26 +03:00
|
|
|
string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME)
|
|
|
|
|
2020-12-19 02:35:28 +03:00
|
|
|
write_basic_package_version_file(
|
2022-05-02 13:02:28 +03:00
|
|
|
${PACKAGE_NAME}-config-version.cmake
|
2020-12-19 02:35:28 +03:00
|
|
|
VERSION ${UVATLAS_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion)
|
|
|
|
|
|
|
|
install(TARGETS ${PROJECT_NAME}
|
|
|
|
EXPORT ${PROJECT_NAME}-targets
|
2022-05-02 13:02:28 +03:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2020-12-19 02:35:28 +03:00
|
|
|
|
2022-12-08 05:09:41 +03:00
|
|
|
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/build/${PROJECT_NAME}-config.cmake.in
|
2022-05-02 13:02:28 +03:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
|
2022-06-03 10:44:31 +03:00
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2020-12-19 02:35:28 +03:00
|
|
|
|
|
|
|
install(EXPORT ${PROJECT_NAME}-targets
|
|
|
|
FILE ${PROJECT_NAME}-targets.cmake
|
|
|
|
NAMESPACE Microsoft::
|
2022-06-03 10:44:31 +03:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2019-12-01 21:23:59 +03:00
|
|
|
|
2020-12-19 02:35:28 +03:00
|
|
|
install(FILES ${LIBRARY_HEADERS}
|
2022-05-02 13:02:28 +03:00
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2020-12-19 02:35:28 +03:00
|
|
|
|
2022-05-02 13:02:28 +03:00
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake
|
2022-06-03 10:44:31 +03:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PACKAGE_NAME})
|
2020-12-19 02:35:28 +03:00
|
|
|
|
|
|
|
#--- Command-line tool
|
2023-03-18 01:47:13 +03:00
|
|
|
if(BUILD_TOOLS AND WIN32)
|
2022-05-04 11:57:28 +03:00
|
|
|
set(TOOL_EXES uvatlastool)
|
|
|
|
|
2023-02-10 05:54:37 +03:00
|
|
|
message(STATUS "Using DirectXMesh and DirectXTex (required for uvatlastool).")
|
2022-05-04 11:57:28 +03:00
|
|
|
|
2020-12-19 02:35:28 +03:00
|
|
|
find_package(directxmesh CONFIG REQUIRED COMPONENTS library utils)
|
|
|
|
find_package(directxtex CONFIG REQUIRED)
|
2019-12-12 03:42:55 +03:00
|
|
|
|
|
|
|
add_executable(uvatlastool
|
|
|
|
UVAtlasTool/UVAtlas.cpp
|
|
|
|
UVAtlasTool/Mesh.cpp
|
|
|
|
UVAtlasTool/Mesh.h
|
|
|
|
UVAtlasTool/MeshOBJ.cpp
|
|
|
|
UVAtlasTool/SDKMesh.h)
|
2022-05-04 11:57:28 +03:00
|
|
|
target_link_libraries(uvatlastool
|
|
|
|
${PROJECT_NAME}
|
|
|
|
ole32.lib version.lib
|
|
|
|
Microsoft::DirectXMesh
|
|
|
|
Microsoft::DirectXTex
|
|
|
|
Microsoft::DirectXMesh::Utilities)
|
2022-05-06 11:25:54 +03:00
|
|
|
source_group(uvatlastool REGULAR_EXPRESSION UVAtlasTool/*.*)
|
2021-02-04 21:24:46 +03:00
|
|
|
|
2023-05-01 20:41:59 +03:00
|
|
|
if(UVATLAS_USE_OPENMP)
|
|
|
|
target_link_libraries(uvatlastool OpenMP::OpenMP_CXX)
|
|
|
|
endif()
|
|
|
|
|
2023-02-10 05:54:37 +03:00
|
|
|
if(directxmath_FOUND)
|
2021-02-04 21:24:46 +03:00
|
|
|
target_link_libraries(uvatlastool Microsoft::DirectXMath)
|
|
|
|
endif()
|
2019-12-12 03:42:55 +03:00
|
|
|
endif()
|
2019-12-01 21:23:59 +03:00
|
|
|
|
2019-12-02 21:52:46 +03:00
|
|
|
if(MSVC)
|
2022-05-04 11:57:28 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2022-11-15 23:59:47 +03:00
|
|
|
target_compile_options(${t} PRIVATE /Wall /GR- /fp:fast "$<$<NOT:$<CONFIG:DEBUG>>:/guard:cf>")
|
2022-05-04 11:57:28 +03:00
|
|
|
target_link_options(${t} PRIVATE /DYNAMICBASE /NXCOMPAT)
|
|
|
|
endforeach()
|
|
|
|
|
2023-04-25 00:10:07 +03:00
|
|
|
if((CMAKE_SIZEOF_VOID_P EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm"))
|
2022-12-08 05:09:41 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_link_options(${t} PRIVATE /SAFESEH)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_SPECTRE_MITIGATION
|
|
|
|
AND (MSVC_VERSION GREATER_EQUAL 1913)
|
|
|
|
AND (NOT WINDOWS_STORE)
|
|
|
|
AND (NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
|
|
|
|
message(STATUS "Building Spectre-mitigated libraries.")
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE "/Qspectre")
|
|
|
|
endforeach()
|
2019-12-02 21:52:46 +03:00
|
|
|
endif()
|
2022-07-26 04:10:05 +03:00
|
|
|
|
2022-12-08 05:09:41 +03:00
|
|
|
if((MSVC_VERSION GREATER_EQUAL 1928)
|
|
|
|
AND (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
2022-07-26 09:43:59 +03:00
|
|
|
AND ((NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)))
|
2022-07-26 04:10:05 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE "$<$<NOT:$<CONFIG:DEBUG>>:/guard:ehcont>")
|
|
|
|
target_link_options(${t} PRIVATE "$<$<NOT:$<CONFIG:DEBUG>>:/guard:ehcont>")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2022-12-03 09:49:20 +03:00
|
|
|
else()
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_definitions(${t} PRIVATE $<IF:$<CONFIG:DEBUG>,_DEBUG,NDEBUG>)
|
|
|
|
endforeach()
|
2019-12-01 21:23:59 +03:00
|
|
|
endif()
|
|
|
|
|
2023-02-16 09:06:56 +03:00
|
|
|
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/favor:AMD64 /arch:AVX2,-march=znver2>)
|
|
|
|
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
2023-02-17 09:20:23 +03:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/favor:AMD64 /arch:AVX,-march=btver2>)
|
2023-02-16 09:06:56 +03:00
|
|
|
elseif(NOT (${DIRECTX_ARCH} MATCHES "^arm"))
|
2023-04-25 00:10:07 +03:00
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
2022-05-06 00:57:10 +03:00
|
|
|
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>)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE ${ARCH_SSE2})
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2022-12-03 09:49:20 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2022-11-15 23:59:47 +03:00
|
|
|
set(WarningsLib -Wall -Wpedantic -Wextra)
|
2023-04-28 03:03:53 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
|
|
|
|
list(APPEND WarningsLib "-Wno-unsafe-buffer-usage")
|
|
|
|
endif()
|
2019-12-01 21:23:59 +03:00
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
|
|
|
|
|
2022-05-04 11:57:28 +03:00
|
|
|
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-exit-time-destructors" "-Wno-switch" "-Wno-switch-enum" "-Wno-language-extension-token" "-Wno-missing-prototypes")
|
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
|
|
|
endforeach()
|
2022-11-27 23:07:54 +03:00
|
|
|
elseif(MINGW)
|
2022-05-06 00:57:10 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE "-Wno-ignored-attributes")
|
|
|
|
target_link_options(${t} PRIVATE -municode)
|
|
|
|
endforeach()
|
2022-12-03 09:49:20 +03:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
2022-05-04 11:57:28 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2022-12-15 21:28:49 +03:00
|
|
|
target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus /Zc:inline)
|
2022-05-04 11:57:28 +03:00
|
|
|
endforeach()
|
2020-05-20 06:23:06 +03:00
|
|
|
|
2022-03-19 11:07:51 +03:00
|
|
|
if(ENABLE_CODE_ANALYSIS)
|
2022-05-04 11:57:28 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /analyze)
|
|
|
|
endforeach()
|
2022-03-19 11:07:51 +03:00
|
|
|
endif()
|
|
|
|
|
2023-02-16 09:06:56 +03:00
|
|
|
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION)
|
|
|
|
message(STATUS "Building using Whole Program Optimization")
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /Gy /Gw)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2022-12-03 09:49:20 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24)
|
2022-05-04 11:57:28 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /ZH:SHA_256)
|
|
|
|
endforeach()
|
2022-03-19 11:07:51 +03:00
|
|
|
endif()
|
2020-06-06 01:18:07 +03:00
|
|
|
|
2022-12-03 09:49:20 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
|
2022-05-04 11:57:28 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /Zc:preprocessor /wd5105)
|
|
|
|
endforeach()
|
2020-05-20 06:23:06 +03:00
|
|
|
endif()
|
2019-12-01 21:23:59 +03:00
|
|
|
|
2022-12-03 09:49:20 +03:00
|
|
|
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) AND (NOT (${DIRECTX_ARCH} MATCHES "^arm")))
|
2022-05-04 11:57:28 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_link_options(${t} PRIVATE /CETCOMPAT)
|
|
|
|
endforeach()
|
2022-03-19 11:07:51 +03:00
|
|
|
endif()
|
|
|
|
|
2022-12-15 21:28:49 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28)
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /Zc:lambda)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2020-06-06 01:18:07 +03:00
|
|
|
if(UVATLAS_USE_OPENMP)
|
2023-05-01 20:41:59 +03:00
|
|
|
# OpenMP in MSVC is not compatible with /permissive- unless you disable two-phase lookup
|
2022-05-04 11:57:28 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
2023-05-01 20:41:59 +03:00
|
|
|
target_compile_options(${t} PRIVATE /Zc:twoPhase-)
|
2022-05-04 11:57:28 +03:00
|
|
|
endforeach()
|
2020-02-10 20:44:45 +03:00
|
|
|
endif()
|
|
|
|
|
2023-02-16 09:06:56 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.35)
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_options(${t} PRIVATE /Zc:templateScope /Zc:checkGwOdr)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2022-05-04 11:57:28 +03:00
|
|
|
set(WarningsEXE "/wd4365" "/wd4514" "/wd4625" "/wd4626" "/wd4627" "/wd4668" "/wd4710" "/wd4751" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd4061" "/wd4062" "/wd5219")
|
2022-12-03 09:49:20 +03:00
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.34)
|
2022-10-18 05:33:22 +03:00
|
|
|
list(APPEND WarningsEXE "/wd5262" "/wd5264")
|
|
|
|
target_compile_options(${PROJECT_NAME} PRIVATE "/wd5262")
|
|
|
|
endif()
|
|
|
|
|
2022-05-04 11:57:28 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES)
|
|
|
|
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
|
|
|
endforeach()
|
2019-12-01 21:23:59 +03:00
|
|
|
endif()
|
|
|
|
|
2022-05-04 11:57:28 +03:00
|
|
|
if(WIN32)
|
2023-02-10 05:54:37 +03:00
|
|
|
if(WINDOWS_STORE OR (${DIRECTX_ARCH} MATCHES "^arm64") OR (DEFINED XBOX_CONSOLE_TARGET))
|
2022-11-15 23:59:47 +03:00
|
|
|
set(WINVER 0x0A00)
|
|
|
|
elseif(${DIRECTX_ARCH} MATCHES "^arm")
|
|
|
|
set(WINVER 0x0602)
|
2020-12-25 00:12:02 +03:00
|
|
|
else()
|
2022-11-15 23:59:47 +03:00
|
|
|
set(WINVER 0x0601)
|
2020-12-25 00:12:02 +03:00
|
|
|
endif()
|
2022-05-06 00:57:10 +03:00
|
|
|
|
2022-11-15 23:59:47 +03:00
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_definitions(${t} PRIVATE _UNICODE UNICODE _WIN32_WINNT=${WINVER})
|
2022-05-04 11:57:28 +03:00
|
|
|
endforeach()
|
2023-01-02 22:26:58 +03:00
|
|
|
|
|
|
|
if(DISABLE_MSVC_ITERATOR_DEBUGGING)
|
|
|
|
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
|
|
|
target_compile_definitions(${t} PRIVATE _ITERATOR_DEBUG_LEVEL=0)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2019-12-12 02:08:37 +03:00
|
|
|
endif()
|
2020-08-11 06:15:30 +03:00
|
|
|
|
2023-03-18 01:47:13 +03:00
|
|
|
if(BUILD_TOOLS AND WIN32)
|
2020-08-11 06:15:30 +03:00
|
|
|
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT uvatlastool)
|
|
|
|
endif()
|
2022-11-22 22:23:50 +03:00
|
|
|
|
|
|
|
#--- Test suite
|
|
|
|
include(CTest)
|
2023-03-18 01:47:13 +03:00
|
|
|
if(BUILD_TESTING AND WIN32 AND (NOT WINDOWS_STORE) AND (NOT (DEFINED XBOX_CONSOLE_TARGET))
|
|
|
|
AND (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Tests/CMakeLists.txt"))
|
2022-11-22 22:23:50 +03:00
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/Tests)
|
|
|
|
endif()
|