CMake file code review
This commit is contained in:
Родитель
a1c4bc3ad6
Коммит
d8cf46ba89
|
@ -5,8 +5,9 @@
|
|||
#
|
||||
# http://go.microsoft.com/fwlink/?LinkID=324981
|
||||
|
||||
cmake_minimum_required (VERSION 3.8)
|
||||
project (DirectXMesh_CMake LANGUAGES CXX)
|
||||
cmake_minimum_required (VERSION 3.11)
|
||||
|
||||
project (DirectXMesh LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
@ -16,10 +17,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
|||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/CMake")
|
||||
|
||||
set(WarningsLib "-Wall" "-Wpedantic" "-Wextra")
|
||||
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-double-promotion" "-Wno-exit-time-destructors" "-Wno-missing-prototypes")
|
||||
|
||||
add_library (directxmesh STATIC
|
||||
add_library (${PROJECT_NAME} STATIC
|
||||
DirectXMesh/DirectXMesh.h
|
||||
DirectXMesh/DirectXMeshP.h
|
||||
DirectXMesh/scoped.h
|
||||
|
@ -39,12 +37,14 @@ add_library (directxmesh STATIC
|
|||
DirectXMesh/DirectXMeshWeldVertices.cpp
|
||||
)
|
||||
|
||||
source_group(DirectXMesh REGULAR_EXPRESSION DirectXMesh/*.*)
|
||||
source_group(meshconvert REGULAR_EXPRESSION meshconvert/*.*)
|
||||
source_group(${PROJECT_NAME} REGULAR_EXPRESSION DirectXMesh/*.*)
|
||||
|
||||
target_include_directories( directxmesh PUBLIC DirectXMesh )
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC DirectXMesh)
|
||||
|
||||
target_compile_options( directxmesh PRIVATE /fp:fast )
|
||||
# Use max Warning Level
|
||||
string(REPLACE "/W3" "/Wall" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
string(REPLACE "/W3" "/Wall" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
string(REPLACE "/W3" "/Wall" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
|
||||
add_executable(meshconvert
|
||||
meshconvert/meshconvert.cpp
|
||||
|
@ -53,19 +53,30 @@ add_executable(meshconvert
|
|||
meshconvert/Mesh.cpp
|
||||
meshconvert/SDKMesh.h)
|
||||
target_include_directories(meshconvert PUBLIC MeshConvert Utilities)
|
||||
target_link_libraries(meshconvert directxmesh)
|
||||
target_link_libraries(meshconvert ${PROJECT_NAME})
|
||||
source_group(meshconvert REGULAR_EXPRESSION meshconvert/*.*)
|
||||
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
target_compile_options( directxmesh PRIVATE ${WarningsLib} )
|
||||
target_compile_options( meshconvert PRIVATE ${WarningsEXE} )
|
||||
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4")
|
||||
target_compile_options( directxmesh PRIVATE /arch:SSE2 )
|
||||
target_compile_options( meshconvert PRIVATE /arch:SSE2 )
|
||||
endif()
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast)
|
||||
target_compile_options(meshconvert PRIVATE /fp:fast)
|
||||
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL "4")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /arch:SSE2)
|
||||
target_compile_options(meshconvert PRIVATE /arch:SSE2)
|
||||
endif()
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
||||
target_compile_options( directxmesh PRIVATE /Wall /permissive- /Zc:__cplusplus )
|
||||
target_compile_options( meshconvert PRIVATE /Wall /permissive- /Zc:__cplusplus )
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(WarningsLib "-Wpedantic" "-Wextra")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
|
||||
|
||||
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-double-promotion" "-Wno-exit-time-destructors" "-Wno-missing-prototypes")
|
||||
target_compile_options(meshconvert PRIVATE ${WarningsEXE})
|
||||
endif()
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /permissive- /JMC- /Zc:__cplusplus)
|
||||
target_compile_options(meshconvert PRIVATE /permissive- /JMC- /Zc:__cplusplus)
|
||||
|
||||
set(WarningsEXE "/wd4061" "/wd4365" "/wd4668" "/wd4710" "/wd4820" "/wd5039" "/wd5045")
|
||||
target_compile_options(meshconvert PRIVATE ${WarningsEXE})
|
||||
endif()
|
||||
|
||||
# Windows 10 is used here to build the DirectX 12 code paths as well as 11
|
||||
|
|
Загрузка…
Ссылка в новой задаче