mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-12 07:36:14 +01:00
CMake support added for building with MinGW (#275)
This commit is contained in:
@@ -156,7 +156,7 @@ if(ENABLE_OPENEXR_SUPPORT)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENEXR_INCLUDE_DIRS}/OpenEXR)
|
||||
endif()
|
||||
|
||||
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
|
||||
if ((${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16") AND (NOT MINGW))
|
||||
target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h)
|
||||
endif()
|
||||
|
||||
@@ -172,7 +172,7 @@ if(MSVC)
|
||||
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
endif()
|
||||
|
||||
if ((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)
|
||||
@@ -268,7 +268,7 @@ if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32 AND (NOT WINDOWS_STORE))
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ((NOT WIN32) OR VCPKG_TOOLCHAIN)
|
||||
if (MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN)
|
||||
foreach(t IN LISTS TOOL_EXES)
|
||||
target_link_libraries(${t} Microsoft::DirectXMath)
|
||||
endforeach()
|
||||
@@ -282,12 +282,23 @@ if(MSVC)
|
||||
|
||||
if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm"))
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /arch:SSE2)
|
||||
target_link_options(${t} PRIVATE /SAFESEH)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ${DIRECTX_ARCH} MATCHES "^arm")
|
||||
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>)
|
||||
endif()
|
||||
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE ${ARCH_SSE2})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(WarningsLib "-Wpedantic" "-Wextra")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
|
||||
@@ -299,6 +310,12 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
||||
endforeach()
|
||||
endif()
|
||||
if(MINGW)
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE -Wno-ignored-attributes)
|
||||
target_link_options(${t} PRIVATE -municode)
|
||||
endforeach()
|
||||
endif()
|
||||
if (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)
|
||||
|
||||
Reference in New Issue
Block a user