Fix configuration conflicts with Clang
- On Windows you can use Clang with both MSVC and MinGW - When using Clang with MSVC all the MSVC conditions should be fulfilled - When using Clang with MinGW all the MSVC steps should not be run
This commit is contained in:
parent
2b79ae96d9
commit
9e27096c37
@ -217,12 +217,12 @@ if(SFML_OS_WINDOWS)
|
|||||||
sfml_set_option(SFML_USE_STATIC_STD_LIBS FALSE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs")
|
sfml_set_option(SFML_USE_STATIC_STD_LIBS FALSE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs")
|
||||||
|
|
||||||
# the following combination of flags is not valid
|
# the following combination of flags is not valid
|
||||||
if (BUILD_SHARED_LIBS AND SFML_USE_STATIC_STD_LIBS)
|
if(BUILD_SHARED_LIBS AND SFML_USE_STATIC_STD_LIBS)
|
||||||
message(FATAL_ERROR "BUILD_SHARED_LIBS and SFML_USE_STATIC_STD_LIBS cannot be used together")
|
message(FATAL_ERROR "BUILD_SHARED_LIBS and SFML_USE_STATIC_STD_LIBS cannot be used together")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# for VC++, we can apply it globally by modifying the compiler flags
|
# for VC++, we can apply it globally by modifying the compiler flags
|
||||||
if(SFML_COMPILER_MSVC AND SFML_USE_STATIC_STD_LIBS)
|
if((SFML_COMPILER_MSVC OR (SFML_COMPILER_CLANG AND NOT MINGW)) AND SFML_USE_STATIC_STD_LIBS)
|
||||||
foreach(flag
|
foreach(flag
|
||||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||||
@ -421,7 +421,7 @@ if(SFML_OS_WINDOWS)
|
|||||||
install(DIRECTORY extlibs/bin/x86/ DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(DIRECTORY extlibs/bin/x86/ DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
if(SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14)
|
if(SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14)
|
||||||
install(DIRECTORY extlibs/libs-msvc/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(DIRECTORY extlibs/libs-msvc/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
elseif(SFML_COMPILER_MSVC)
|
elseif(SFML_COMPILER_MSVC OR (SFML_COMPILER_CLANG AND NOT MINGW))
|
||||||
install(DIRECTORY extlibs/libs-msvc-universal/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(DIRECTORY extlibs/libs-msvc-universal/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
else()
|
else()
|
||||||
install(DIRECTORY extlibs/libs-mingw/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(DIRECTORY extlibs/libs-mingw/x86/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
@ -430,7 +430,7 @@ if(SFML_OS_WINDOWS)
|
|||||||
install(DIRECTORY extlibs/bin/x64/ DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(DIRECTORY extlibs/bin/x64/ DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
if(SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14)
|
if(SFML_COMPILER_MSVC AND SFML_MSVC_VERSION LESS 14)
|
||||||
install(DIRECTORY extlibs/libs-msvc/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(DIRECTORY extlibs/libs-msvc/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
elseif(SFML_COMPILER_MSVC)
|
elseif(SFML_COMPILER_MSVC OR (SFML_COMPILER_CLANG AND NOT MINGW))
|
||||||
install(DIRECTORY extlibs/libs-msvc-universal/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(DIRECTORY extlibs/libs-msvc-universal/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
else()
|
else()
|
||||||
install(DIRECTORY extlibs/libs-mingw/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(DIRECTORY extlibs/libs-mingw/x64/ DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
@ -82,27 +82,12 @@ if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# detect the compiler and its version
|
# detect the compiler and its version
|
||||||
# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
|
# Note: The detection is order is important because:
|
||||||
# even when CLANG is used, therefore the Clang test is done first
|
# - Visual Studio can both use MSVC and Clang
|
||||||
if(CMAKE_CXX_COMPILER MATCHES "clang[+][+]" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
# - GNUCXX can still be set on macOS when using Clang
|
||||||
# CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
|
if(MSVC)
|
||||||
# but there is no other way to detect CLang at the moment
|
|
||||||
set(SFML_COMPILER_CLANG 1)
|
|
||||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
|
|
||||||
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
|
||||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
set(SFML_COMPILER_GCC 1)
|
|
||||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
|
||||||
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}")
|
|
||||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION)
|
|
||||||
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
|
|
||||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
|
|
||||||
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
|
|
||||||
if(GCC_MACHINE MATCHES ".*w64.*")
|
|
||||||
set(SFML_COMPILER_GCC_W64 1)
|
|
||||||
endif()
|
|
||||||
elseif(MSVC)
|
|
||||||
set(SFML_COMPILER_MSVC 1)
|
set(SFML_COMPILER_MSVC 1)
|
||||||
|
|
||||||
if(MSVC_VERSION EQUAL 1400)
|
if(MSVC_VERSION EQUAL 1400)
|
||||||
set(SFML_MSVC_VERSION 8)
|
set(SFML_MSVC_VERSION 8)
|
||||||
elseif(MSVC_VERSION EQUAL 1500)
|
elseif(MSVC_VERSION EQUAL 1500)
|
||||||
@ -115,6 +100,28 @@ elseif(MSVC)
|
|||||||
set(SFML_MSVC_VERSION 12)
|
set(SFML_MSVC_VERSION 12)
|
||||||
elseif(MSVC_VERSION EQUAL 1900)
|
elseif(MSVC_VERSION EQUAL 1900)
|
||||||
set(SFML_MSVC_VERSION 14)
|
set(SFML_MSVC_VERSION 14)
|
||||||
|
elseif(MSVC_VERSION LESS_EQUAL 1919)
|
||||||
|
set(SFML_MSVC_VERSION 15)
|
||||||
|
elseif(MSVC_VERSION LESS_EQUAL 1929)
|
||||||
|
set(SFML_MSVC_VERSION 16)
|
||||||
|
endif()
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
set(SFML_COMPILER_CLANG 1)
|
||||||
|
|
||||||
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
|
||||||
|
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
||||||
|
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
set(SFML_COMPILER_GCC 1)
|
||||||
|
|
||||||
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
||||||
|
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}")
|
||||||
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION)
|
||||||
|
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
|
||||||
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
|
||||||
|
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
|
||||||
|
|
||||||
|
if(GCC_MACHINE MATCHES ".*w64.*")
|
||||||
|
set(SFML_COMPILER_GCC_W64 1)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported compiler")
|
message(FATAL_ERROR "Unsupported compiler")
|
||||||
|
@ -5,7 +5,7 @@ include(${PROJECT_SOURCE_DIR}/cmake/Macros.cmake)
|
|||||||
# let CMake know about our additional libraries paths
|
# let CMake know about our additional libraries paths
|
||||||
if (SFML_OS_WINDOWS)
|
if (SFML_OS_WINDOWS)
|
||||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers")
|
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers")
|
||||||
if(SFML_COMPILER_GCC)
|
if(SFML_COMPILER_GCC OR (SFML_COMPILER_CLANG AND MINGW))
|
||||||
if(ARCH_32BITS)
|
if(ARCH_32BITS)
|
||||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x86")
|
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x86")
|
||||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x86")
|
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x86")
|
||||||
@ -13,7 +13,7 @@ if (SFML_OS_WINDOWS)
|
|||||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x64")
|
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-mingw/x64")
|
||||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x64")
|
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/bin/x64")
|
||||||
endif()
|
endif()
|
||||||
elseif(SFML_COMPILER_MSVC OR SFML_COMPILER_CLANG)
|
elseif(SFML_COMPILER_MSVC OR (SFML_COMPILER_CLANG AND NOT MINGW))
|
||||||
if(SFML_MSVC_VERSION LESS 14)
|
if(SFML_MSVC_VERSION LESS 14)
|
||||||
if(ARCH_32BITS)
|
if(ARCH_32BITS)
|
||||||
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc/x86")
|
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc/x86")
|
||||||
|
@ -119,7 +119,7 @@ endif()
|
|||||||
|
|
||||||
# starting from Visual Studio 2015, inline versions of some C functions are used; for compatibility link this library
|
# starting from Visual Studio 2015, inline versions of some C functions are used; for compatibility link this library
|
||||||
# see https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp?view=msvc-160#libraries
|
# see https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp?view=msvc-160#libraries
|
||||||
if(SFML_COMPILER_MSVC AND MSVC_VERSION GREATER_EQUAL 1900)
|
if((SFML_COMPILER_MSVC AND SFML_MSVC_VERSION GREATER_EQUAL 14) OR (SFML_COMPILER_CLANG AND SFML_OS_WINDOWS AND NOT MINGW))
|
||||||
target_link_libraries(sfml-graphics PRIVATE legacy_stdio_definitions.lib)
|
target_link_libraries(sfml-graphics PRIVATE legacy_stdio_definitions.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user