From 165f2b1888c86050d2bc43943311416b7f2dee25 Mon Sep 17 00:00:00 2001 From: Baruch Date: Tue, 1 May 2012 23:00:24 +0300 Subject: [PATCH 1/2] fix for static builds with mingw-w64 compilers - part 1 --- cmake/Config.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 7fed4ac4..ce9bb2c1 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -1,4 +1,3 @@ - # detect the OS if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(WINDOWS 1) @@ -47,6 +46,11 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) set(COMPILER_GCC 1) execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT) string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" GCC_VERSION "${GCC_VERSION_OUTPUT}") + execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE) + string(STRIP "${GCC_MACHINE}" GCC_MACHINE) + if(${GCC_MACHINE} MATCHES ".*w64.*") + set(COMPILER_GCC_W64 1) + endif() elseif(MSVC) set(COMPILER_MSVC 1) if(MSVC_VERSION EQUAL 1400) From f784fe4c07da52b2e85d9c612bf8a027718c9b5c Mon Sep 17 00:00:00 2001 From: Baruch Date: Tue, 1 May 2012 23:01:56 +0300 Subject: [PATCH 2/2] fix for static builds with mingw-w64 compilers - part 2 --- cmake/Macros.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 303c6290..729ed306 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -1,4 +1,3 @@ - # some of these macros are inspired from the boost/cmake macros # this macro adds external dependencies to a static target, @@ -16,7 +15,11 @@ macro(sfml_static_add_libraries target) foreach(lib ${ARGN}) if(NOT ${lib} MATCHES ".*/.*") string(REGEX REPLACE "(.*)/bin/.*\\.exe" "\\1" STANDARD_LIBS_PATH "${CMAKE_CXX_COMPILER}") - set(lib "${STANDARD_LIBS_PATH}/lib/lib${lib}.a") + if(COMPILER_GCC_W64) + set(lib "${STANDARD_LIBS_PATH}/${GCC_MACHINE}/lib/lib${lib}.a") + else() + set(lib "${STANDARD_LIBS_PATH}/lib/lib${lib}.a") + endif() endif() string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE) get_target_property(TARGET_FILENAME ${target} ${BUILD_TYPE}_LOCATION) @@ -43,7 +46,7 @@ macro(sfml_static_add_libraries target) endif() endforeach() set_target_properties(${target} PROPERTIES STATIC_LIBRARY_FLAGS ${LIBRARIES}) - else() + else() # All other platforms target_link_libraries(${target} ${ARGN}) endif()