mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 13:53:36 +02:00
Updated build files to reflect the latest changes in SFML
This commit is contained in:
1 parent
85a648ccc6
commit
6669a6590a
10 files changed
+62
-91
No files matched your search
+13
-7
@@ -1,11 +1,17 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# define a macro that helps defining an option
|
||||
macro(csfml_set_option var default type docstring)
|
||||
if(NOT DEFINED ${var})
|
||||
set(${var} ${default})
|
||||
endif()
|
||||
set(${var} ${${var}} CACHE ${type} ${docstring} FORCE)
|
||||
endmacro()
|
||||
|
||||
# set a default build type if none was provided
|
||||
# this has to be done before the project() instruction!
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
|
||||
endif()
|
||||
csfml_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")
|
||||
|
||||
# project name
|
||||
project(CSFML)
|
||||
@@ -21,11 +27,11 @@ set(VERSION_PATCH 0)
|
||||
# add the CSFML header path
|
||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
# force dynamic build (static build is not supported)
|
||||
set(BUILD_SHARED_LIBS TRUE)
|
||||
# add an option for choosing the build type (shared or static)
|
||||
csfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build CSFML as shared libraries, FALSE to build it as static libraries")
|
||||
|
||||
# add an option for building the API documentation
|
||||
set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
|
||||
csfml_set_option(CSFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
|
||||
|
||||
# disable the rpath stuff
|
||||
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||
@@ -48,7 +54,7 @@ endif()
|
||||
|
||||
# add the subdirectories
|
||||
add_subdirectory(src/SFML)
|
||||
if(BUILD_DOC)
|
||||
if(CSFML_BUILD_DOC)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
|
||||
|
||||
+26
-19
@@ -1,26 +1,24 @@
|
||||
|
||||
# detect the OS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(WINDOWS 1)
|
||||
set(SFML_OS_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")
|
||||
if("${SIZEOF_VOID_PTR}" STREQUAL "4")
|
||||
set(ARCH_32BITS 1)
|
||||
elseif(${SIZEOF_VOID_PTR} EQUAL "8")
|
||||
elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
|
||||
set(ARCH_64BITS 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported architecture")
|
||||
return()
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(LINUX 1)
|
||||
set(SFML_OS_LINUX 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
# FreeBSD compile path is the same as Linux
|
||||
set(LINUX 1)
|
||||
set(SFML_OS_FREEBSD 1)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(MACOSX 1)
|
||||
set(SFML_OS_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)
|
||||
@@ -40,23 +38,32 @@ endif()
|
||||
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)
|
||||
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" CLANG_VERSION "${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(COMPILER_GCC 1)
|
||||
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" GCC_VERSION "${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(COMPILER_MSVC 1)
|
||||
set(SFML_COMPILER_MSVC 1)
|
||||
if(MSVC_VERSION EQUAL 1400)
|
||||
set(MSVC_VERSION 2005)
|
||||
set(SFML_MSVC_VERSION 8)
|
||||
elseif(MSVC_VERSION EQUAL 1500)
|
||||
set(MSVC_VERSION 2008)
|
||||
set(SFML_MSVC_VERSION 9)
|
||||
elseif(MSVC_VERSION EQUAL 1600)
|
||||
set(MSVC_VERSION 2010)
|
||||
set(SFML_MSVC_VERSION 10)
|
||||
elseif(MSVC_VERSION EQUAL 1700)
|
||||
set(MSVC_VERSION 2011)
|
||||
set(SFML_MSVC_VERSION 11)
|
||||
elseif(MSVC_VERSION EQUAL 1800)
|
||||
set(SFML_MSVC_VERSION 12)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported compiler")
|
||||
@@ -64,8 +71,8 @@ else()
|
||||
endif()
|
||||
|
||||
# define the install directory for miscellaneous files
|
||||
if(WINDOWS)
|
||||
if(SFML_OS_WINDOWS)
|
||||
set(INSTALL_MISC_DIR .)
|
||||
elseif(UNIX)
|
||||
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
|
||||
set(INSTALL_MISC_DIR share/CSFML)
|
||||
endif()
|
||||
+13
-55
@@ -1,50 +1,4 @@
|
||||
|
||||
# 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(csfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
@@ -52,7 +6,7 @@ endmacro()
|
||||
macro(csfml_add_library target)
|
||||
|
||||
# parse the arguments
|
||||
csfml_parse_arguments(THIS "SOURCES;DEPENDS" "" ${ARGN})
|
||||
cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;EXTERNAL_LIBS" ${ARGN})
|
||||
|
||||
# create the target
|
||||
add_library(${target} ${THIS_SOURCES})
|
||||
@@ -62,15 +16,14 @@ macro(csfml_add_library 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)
|
||||
if(SFML_OS_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)
|
||||
if (SFML_OS_WINDOWS AND SFML_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 "")
|
||||
@@ -81,16 +34,21 @@ 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.0 on Windows, apply the STATIC_STD_LIBS option if it is enabled
|
||||
if(WINDOWS AND COMPILER_GCC AND STATIC_STD_LIBS)
|
||||
if(NOT GCC_VERSION VERSION_LESS "4")
|
||||
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "CSFML")
|
||||
|
||||
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4")
|
||||
if(SFML_USE_STATIC_STD_LIBS AND NOT SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
|
||||
elseif(NOT SFML_USE_STATIC_STD_LIBS AND SFML_COMPILER_GCC_TDM)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-shared-libgcc -shared-libstdc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# If using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
|
||||
# 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")))
|
||||
if(NOT SFML_OS_WINDOWS AND ((SFML_COMPILER_GCC AND NOT SFML_GCC_VERSION VERSION_LESS "4") OR (SFML_COMPILER_CLANG AND NOT SFML_CLANG_VERSION VERSION_LESS "3")))
|
||||
set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ set(DOXYGEN_INPUT_DIR ${CMAKE_SOURCE_DIR})
|
||||
set(DOXYGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/doc)
|
||||
|
||||
# see if we can generate the CHM documentation
|
||||
if(WINDOWS)
|
||||
if(SFML_OS_WINDOWS)
|
||||
# if HHC is found, we can generate the CHM (compressed HTML) output
|
||||
find_program(DOXYGEN_HHC_PROGRAM
|
||||
NAMES hhc.exe
|
||||
|
||||
@@ -32,4 +32,4 @@ set(SRC
|
||||
# define the csfml-audio target
|
||||
csfml_add_library(csfml-audio
|
||||
SOURCES ${SRC}
|
||||
DEPENDS ${SFML_AUDIO_LIBRARY} ${SFML_SYSTEM_LIBRARY})
|
||||
DEPENDS ${SFML_AUDIO_LIBRARY} ${SFML_SYSTEM_LIBRARY} ${SFML_AUDIO_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES})
|
||||
@@ -12,16 +12,16 @@ set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
|
||||
add_definitions(-DCSFML_EXPORTS)
|
||||
|
||||
# disable stupid warnings with Visual C++
|
||||
if(COMPILER_MSVC)
|
||||
if(SFML_COMPILER_MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
# find SFML libraries (C++)
|
||||
if(WINDOWS)
|
||||
if(SFML_OS_WINDOWS)
|
||||
set(SFML_STATIC_LIBRARIES TRUE)
|
||||
add_definitions(-DSFML_STATIC)
|
||||
endif()
|
||||
find_package(SFML 2.0 COMPONENTS system window network graphics audio REQUIRED)
|
||||
find_package(SFML 2 COMPONENTS system window network graphics audio REQUIRED)
|
||||
include_directories(${SFML_INCLUDE_DIR})
|
||||
|
||||
# add the modules subdirectories
|
||||
@@ -30,6 +30,6 @@ add_subdirectory(Window)
|
||||
add_subdirectory(Network)
|
||||
add_subdirectory(Graphics)
|
||||
add_subdirectory(Audio)
|
||||
if(WINDOWS)
|
||||
if(SFML_OS_WINDOWS)
|
||||
add_subdirectory(Main)
|
||||
endif()
|
||||
@@ -67,4 +67,4 @@ set(SRC
|
||||
# define the csfml-graphics target
|
||||
csfml_add_library(csfml-graphics
|
||||
SOURCES ${SRC}
|
||||
DEPENDS ${SFML_GRAPHICS_LIBRARY} ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY})
|
||||
DEPENDS ${SFML_GRAPHICS_LIBRARY} ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY} ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_WINDOW_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES})
|
||||
@@ -35,4 +35,4 @@ set(SRC
|
||||
# define the csfml-network target
|
||||
csfml_add_library(csfml-network
|
||||
SOURCES ${SRC}
|
||||
DEPENDS ${SFML_NETWORK_LIBRARY} ${SFML_SYSTEM_LIBRARY})
|
||||
DEPENDS ${SFML_NETWORK_LIBRARY} ${SFML_SYSTEM_LIBRARY} ${SFML_NETWORK_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES})
|
||||
@@ -27,4 +27,4 @@ set(SRC
|
||||
# define the csfml-system target
|
||||
csfml_add_library(csfml-system
|
||||
SOURCES ${SRC}
|
||||
DEPENDS ${SFML_SYSTEM_LIBRARY})
|
||||
DEPENDS ${SFML_SYSTEM_LIBRARY} ${SFML_SYSTEM_DEPENDENCIES})
|
||||
@@ -27,4 +27,4 @@ set(SRC
|
||||
# define the csfml-window target
|
||||
csfml_add_library(csfml-window
|
||||
SOURCES ${SRC}
|
||||
DEPENDS ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY})
|
||||
DEPENDS ${SFML_WINDOW_LIBRARY} ${SFML_SYSTEM_LIBRARY} ${SFML_WINDOW_DEPENDENCIES} ${SFML_SYSTEM_DEPENDENCIES})
|
||||
Reference in new issue
Block a user