mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-26 21:16:13 +01:00
Each module now has its own export macro
This commit is contained in:
1 parent
7615382a68
commit
0c5afa3483
70 files changed
+1010
-719
No files matched your search
+41
-21
@@ -2,6 +2,18 @@
|
||||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(WINDOWS 1)
|
||||
|
||||
# detect the architecture (note: this test won't work for cross-compilation)
|
||||
include(CheckTypeSize)
|
||||
check_type_size(void* SIZEOF_VOID_PTR)
|
||||
if(${SIZEOF_VOID_PTR} EQUAL "4")
|
||||
set(ARCH_32BITS 1)
|
||||
elseif(${SIZEOF_VOID_PTR} EQUAL "8")
|
||||
set(ARCH_64BITS 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture")
|
||||
return()
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(LINUX 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
@@ -9,37 +21,45 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
set(LINUX 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(MACOSX 1)
|
||||
|
||||
# detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.)
|
||||
EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
|
||||
STRING(REGEX REPLACE "10\\.([0-9]).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}")
|
||||
if(${MACOSX_VERSION} LESS 5)
|
||||
message(FATAL_ERROR "Unsupported version of OS X : ${MACOSX_VERSION_RAW}")
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Unsupported operating system")
|
||||
message(FATAL_ERROR "Unsupported operating system")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# detect the architecture
|
||||
# note: this test won't work for cross-compilation
|
||||
include(CheckTypeSize)
|
||||
check_type_size(void* SIZEOF_VOID_PTR)
|
||||
if(${SIZEOF_VOID_PTR} MATCHES "^8$")
|
||||
set(ARCH_BITS 64)
|
||||
else()
|
||||
set(ARCH_BITS 32)
|
||||
endif()
|
||||
|
||||
# detect the compiler and its version
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
|
||||
# even when CLANG is used, therefore the Clang test is done first
|
||||
if(CMAKE_CXX_COMPILER MATCHES ".*clang[+][+]" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
|
||||
# but there is no other way to detect CLang at the moment
|
||||
set(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" CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
||||
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}")
|
||||
elseif(MSVC_VERSION EQUAL 1400)
|
||||
elseif(MSVC)
|
||||
set(COMPILER_MSVC 1)
|
||||
set(MSVC_VERSION 2005)
|
||||
elseif(MSVC_VERSION EQUAL 1500)
|
||||
set(COMPILER_MSVC 1)
|
||||
set(MSVC_VERSION 2008)
|
||||
elseif(MSVC_VERSION EQUAL 1600)
|
||||
set(COMPILER_MSVC 1)
|
||||
set(MSVC_VERSION 2010)
|
||||
if(MSVC_VERSION EQUAL 1400)
|
||||
set(MSVC_VERSION 2005)
|
||||
elseif(MSVC_VERSION EQUAL 1500)
|
||||
set(MSVC_VERSION 2008)
|
||||
elseif(MSVC_VERSION EQUAL 1600)
|
||||
set(MSVC_VERSION 2010)
|
||||
elseif(MSVC_VERSION EQUAL 1700)
|
||||
set(MSVC_VERSION 2011)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Unsupported compiler")
|
||||
message(FATAL_ERROR "Unsupported compiler")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
+14
-3
@@ -46,7 +46,7 @@ macro(csfml_parse_arguments prefix arg_names option_names)
|
||||
endmacro()
|
||||
|
||||
# add a new target which is a CSFML library
|
||||
# ex: csfml_add_library(sfml-graphics
|
||||
# ex: csfml_add_library(csfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
# DEPENDS sfml-window sfml-system)
|
||||
macro(csfml_add_library target)
|
||||
@@ -57,6 +57,11 @@ macro(csfml_add_library target)
|
||||
# create the target
|
||||
add_library(${target} ${THIS_SOURCES})
|
||||
|
||||
# define the export symbol of the module
|
||||
string(REPLACE "-" "_" NAME_UPPER "${target}")
|
||||
string(TOUPPER "${NAME_UPPER}" NAME_UPPER)
|
||||
set_target_properties(${target} PROPERTIES DEFINE_SYMBOL ${NAME_UPPER}_EXPORTS)
|
||||
|
||||
# adjust the output file prefix/suffix to match our conventions
|
||||
if(WINDOWS)
|
||||
# include the major version number in Windows shared library names (but not import library names)
|
||||
@@ -76,13 +81,19 @@ macro(csfml_add_library target)
|
||||
set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR})
|
||||
set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
|
||||
|
||||
# for gcc 4.x on Windows, apply the STATIC_STD_LIBS option if it is enabled
|
||||
# for gcc >= 4.0 on Windows, apply the STATIC_STD_LIBS option if it is enabled
|
||||
if(WINDOWS AND COMPILER_GCC AND STATIC_STD_LIBS)
|
||||
if(${GCC_VERSION} MATCHES "4\\..*")
|
||||
if(NOT GCC_VERSION VERSION_LESS "4")
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
|
||||
# (exported ones are explicitely marked)
|
||||
if(NOT WINDOWS AND ((COMPILER_GCC AND NOT GCC_VERSION VERSION_LESS "4") OR (COMPILER_CLANG AND NOT CLANG_VERSION VERSION_LESS "3")))
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
# link the target to its external dependencies (C++ SFML libraries)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
|
||||
|
||||
Reference in new issue
Block a user