CMake code review

This commit is contained in:
Chuck Walbourn 2019-12-13 17:18:02 -08:00
parent 9a8cc96fff
commit b81d71db86

View File

@ -9,6 +9,8 @@ cmake_minimum_required (VERSION 3.11)
project (UVAtlas LANGUAGES CXX)
option(BUILD_TOOLS "Build UVAtlasTool" ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
@ -88,9 +90,7 @@ if(MSVC)
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
endif()
option(BUILD_TOOLS "Build UVAtlasTool" ON)
if(BUILD_TOOLS)
if(BUILD_TOOLS MATCHES ON)
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/../DirectXMesh/CMakeLists.txt")
message(FATAL_ERROR "uvatalastool requires DirectXMesh library from http://go.microsoft.com/fwlink/?LinkID=324981" )
endif()
@ -113,13 +113,13 @@ endif()
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast)
if(BUILD_TOOLS)
if(BUILD_TOOLS MATCHES ON)
target_compile_options(uvatlastool PRIVATE /fp:fast)
endif()
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4")
target_compile_options(${PROJECT_NAME} PRIVATE /arch:SSE2)
if(BUILD_TOOLS)
if(BUILD_TOOLS MATCHES ON)
target_compile_options(uvatlastool PRIVATE /arch:SSE2)
endif()
endif()
@ -129,7 +129,7 @@ if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set(WarningsLib "-Wpedantic" "-Wextra")
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
if(BUILD_TOOLS)
if(BUILD_TOOLS MATCHES ON)
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-exit-time-destructors" "-Wno-switch" "-Wno-switch-enum" "-Wno-language-extension-token" "-Wno-missing-prototypes")
target_compile_options(uvatlastool PRIVATE ${WarningsEXE})
endif()
@ -139,7 +139,7 @@ if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
target_compile_options(${PROJECT_NAME} PRIVATE /permissive- /JMC- /Zc:__cplusplus)
target_compile_options(uvatlastool PRIVATE /permissive- /Zc:__cplusplus)
if(BUILD_TOOLS)
if(BUILD_TOOLS MATCHES ON)
set(WarningsEXE "/wd4365" "/wd4710" "/wd4820" "/wd5039" "/wd5045")
target_compile_options(uvatlastool PRIVATE ${WarningsEXE})
endif()
@ -148,7 +148,7 @@ endif()
if(MSVC)
# We use Windows 7 here
target_compile_definitions(${PROJECT_NAME} PRIVATE _UNICODE UNICODE _WIN32_WINNT=0x0601)
if(BUILD_TOOLS)
if(BUILD_TOOLS MATCHES ON)
target_compile_definitions(uvatlastool PRIVATE _UNICODE UNICODE _WIN32_WINNT=0x0601)
endif()
endif()