mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-27 13:36:12 +01:00
Initial commit -- moved from https://github.com/LaurentGomila/SFML (bindings/c)
This commit is contained in:
commit
45d3b05d65
141 files changed
+19124
No files matched your search
@@ -0,0 +1,48 @@
|
||||
|
||||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(WINDOWS 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(LINUX 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(MACOSX 1)
|
||||
else()
|
||||
message(WARNING "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)
|
||||
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)
|
||||
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)
|
||||
else()
|
||||
message(WARNING "Unsupported compiler")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# define the install directory for miscellaneous files
|
||||
if(WINDOWS)
|
||||
set(INSTALL_MISC_DIR .)
|
||||
elseif(UNIX)
|
||||
set(INSTALL_MISC_DIR share/CSFML)
|
||||
endif()
|
||||
@@ -0,0 +1,95 @@
|
||||
|
||||
# some of these macros are inspired from the boost/cmake macros
|
||||
|
||||
# check if a value is contained in a list
|
||||
# sets ${var} to TRUE if the value is found
|
||||
macro(csfml_list_contains var value)
|
||||
set(${var})
|
||||
foreach(value2 ${ARGN})
|
||||
if(${value} STREQUAL ${value2})
|
||||
set(${var} TRUE)
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# parse a list of arguments and options
|
||||
# ex: sfml_parse_arguments(THIS "SOURCES;DEPENDS" "FLAG" FLAG SOURCES s1 s2 s3 DEPENDS d1 d2)
|
||||
# will define the following variables:
|
||||
# - THIS_SOURCES (s1 s2 s3)
|
||||
# - THIS_DEPENDS (d1 d2)
|
||||
# - THIS_FLAG TRUE
|
||||
macro(csfml_parse_arguments prefix arg_names option_names)
|
||||
foreach(arg_name ${arg_names})
|
||||
set(${prefix}_${arg_name})
|
||||
endforeach()
|
||||
foreach(option_name ${option_names})
|
||||
set(${prefix}_${option_name} FALSE)
|
||||
endforeach()
|
||||
set(current_arg_name)
|
||||
set(current_arg_list)
|
||||
foreach(arg ${ARGN})
|
||||
csfml_list_contains(is_arg_name ${arg} ${arg_names})
|
||||
if(is_arg_name)
|
||||
set(${prefix}_${current_arg_name} ${current_arg_list})
|
||||
set(current_arg_name ${arg})
|
||||
set(current_arg_list)
|
||||
else()
|
||||
csfml_list_contains(is_option ${arg} ${option_names})
|
||||
if(is_option)
|
||||
set(${prefix}_${arg} TRUE)
|
||||
else()
|
||||
set(current_arg_list ${current_arg_list} ${arg})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${prefix}_${current_arg_name} ${current_arg_list})
|
||||
endmacro()
|
||||
|
||||
# add a new target which is a CSFML library
|
||||
# ex: csfml_add_library(sfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
# DEPENDS sfml-window sfml-system)
|
||||
macro(csfml_add_library target)
|
||||
|
||||
# parse the arguments
|
||||
csfml_parse_arguments(THIS "SOURCES;DEPENDS" "" ${ARGN})
|
||||
|
||||
# create the target
|
||||
add_library(${target} ${THIS_SOURCES})
|
||||
|
||||
# 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)
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
set_target_properties(${target} PROPERTIES SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
else()
|
||||
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
|
||||
endif()
|
||||
if (WINDOWS AND COMPILER_GCC)
|
||||
# on Windows/gcc get rid of "lib" prefix for shared libraries,
|
||||
# and transform the ".dll.a" suffix into ".a" for import libraries
|
||||
set_target_properties(${target} PROPERTIES PREFIX "")
|
||||
set_target_properties(${target} PROPERTIES IMPORT_SUFFIX ".a")
|
||||
endif()
|
||||
|
||||
# set the version and soversion of the target (for compatible systems -- mostly Linuxes)
|
||||
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
|
||||
if(WINDOWS AND COMPILER_GCC AND STATIC_STD_LIBS)
|
||||
if(${GCC_VERSION} MATCHES "4\\..*")
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# link the target to its external dependencies (C++ SFML libraries)
|
||||
target_link_libraries(${target} ${THIS_DEPENDS})
|
||||
|
||||
# add the install rule
|
||||
install(TARGETS ${target}
|
||||
RUNTIME DESTINATION bin COMPONENT bin
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel)
|
||||
|
||||
endmacro()
|
||||
Reference in new issue
Block a user