Made compiler and OS variable names much clearer in CMake files

This commit is contained in:
Laurent Gomila 2013-10-09 08:01:10 +02:00
parent fe12270d62
commit 9b0ed300b5
11 changed files with 74 additions and 76 deletions

View File

@ -37,7 +37,7 @@ sfml_set_option(SFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the SFML examples,
sfml_set_option(SFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it") sfml_set_option(SFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
# Mac OS X specific options # Mac OS X specific options
if(MACOSX) if(SFML_OS_MACOSX)
# add an option to build frameworks instead of dylibs (release only) # add an option to build frameworks instead of dylibs (release only)
sfml_set_option(SFML_BUILD_FRAMEWORKS FALSE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS") sfml_set_option(SFML_BUILD_FRAMEWORKS FALSE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
@ -54,12 +54,12 @@ if(NOT BUILD_SHARED_LIBS)
endif() endif()
# remove SL security warnings with Visual C++ # remove SL security warnings with Visual C++
if(COMPILER_MSVC) if(SFML_COMPILER_MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE) add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif() endif()
# define an option for choosing between static and dynamic C runtime (Windows only) # define an option for choosing between static and dynamic C runtime (Windows only)
if(WINDOWS) 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
@ -68,7 +68,7 @@ if(WINDOWS)
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(COMPILER_MSVC AND SFML_USE_STATIC_STD_LIBS) if(SFML_COMPILER_MSVC 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)
@ -83,7 +83,7 @@ endif()
set(CMAKE_SKIP_BUILD_RPATH TRUE) set(CMAKE_SKIP_BUILD_RPATH TRUE)
# setup Mac OS X stuff # setup Mac OS X stuff
if(MACOSX) if(SFML_OS_MACOSX)
# SFML_BUILD_FRAMEWORKS needs two things : # SFML_BUILD_FRAMEWORKS needs two things :
# first, it's available only for release # first, it's available only for release
# (because cmake currently doesn't allow specifying a custom framework name so XXX-d is not possible) # (because cmake currently doesn't allow specifying a custom framework name so XXX-d is not possible)
@ -103,7 +103,7 @@ if(MACOSX)
endif() endif()
endif() endif()
if(LINUX) if(SFML_OS_LINUX OR SFML_OS_FREEBSD)
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES FALSE BOOL "TRUE to automatically install pkg-config files so other projects can find SFML") sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES FALSE BOOL "TRUE to automatically install pkg-config files so other projects can find SFML")
if(SFML_INSTALL_PKGCONFIG_FILES) if(SFML_INSTALL_PKGCONFIG_FILES)
@ -190,7 +190,7 @@ install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR})
install(FILES readme.txt DESTINATION ${INSTALL_MISC_DIR}) install(FILES readme.txt DESTINATION ${INSTALL_MISC_DIR})
if(WINDOWS) if(SFML_OS_WINDOWS)
if(ARCH_32BITS) if(ARCH_32BITS)
install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin) install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin)
install(FILES extlibs/bin/x86/openal32.dll DESTINATION bin) install(FILES extlibs/bin/x86/openal32.dll DESTINATION bin)
@ -198,7 +198,7 @@ if(WINDOWS)
install(FILES extlibs/bin/x64/libsndfile-1.dll DESTINATION bin) install(FILES extlibs/bin/x64/libsndfile-1.dll DESTINATION bin)
install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin) install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin)
endif() endif()
elseif(MACOSX) elseif(SFML_OS_MACOSX)
install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX}) install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
install(DIRECTORY extlibs/libs-osx/Frameworks/freetype.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX}) install(DIRECTORY extlibs/libs-osx/Frameworks/freetype.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})

View File

@ -1,6 +1,6 @@
# detect the OS # detect the OS
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") 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) # detect the architecture (note: this test won't work for cross-compilation)
include(CheckTypeSize) include(CheckTypeSize)
@ -14,13 +14,11 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
return() return()
endif() endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX 1) set(SFML_OS_LINUX 1)
set(UNIX 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(FreeBSD 1) set(SFML_OS_FREEBSD 1)
set(UNIX 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 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'.) # 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) EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
@ -40,28 +38,28 @@ endif()
if(CMAKE_CXX_COMPILER MATCHES ".*clang[+][+]" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 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, # CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
# but there is no other way to detect CLang at the moment # 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) 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) 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) 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}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE) execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
string(STRIP "${GCC_MACHINE}" GCC_MACHINE) string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
if(${GCC_MACHINE} MATCHES ".*w64.*") if(${GCC_MACHINE} MATCHES ".*w64.*")
set(COMPILER_GCC_W64 1) set(SFML_COMPILER_GCC_W64 1)
endif() endif()
elseif(MSVC) elseif(MSVC)
set(COMPILER_MSVC 1) set(SFML_COMPILER_MSVC 1)
if(MSVC_VERSION EQUAL 1400) if(MSVC_VERSION EQUAL 1400)
set(MSVC_VERSION 2005) set(SFML_MSVC_VERSION 2005)
elseif(MSVC_VERSION EQUAL 1500) elseif(SFML_MSVC_VERSION EQUAL 1500)
set(MSVC_VERSION 2008) set(SFML_MSVC_VERSION 2008)
elseif(MSVC_VERSION EQUAL 1600) elseif(SFML_MSVC_VERSION EQUAL 1600)
set(MSVC_VERSION 2010) set(SFML_MSVC_VERSION 2010)
elseif(MSVC_VERSION EQUAL 1700) elseif(SFML_MSVC_VERSION EQUAL 1700)
set(MSVC_VERSION 2011) set(SFML_MSVC_VERSION 2011)
endif() endif()
else() else()
message(FATAL_ERROR "Unsupported compiler") message(FATAL_ERROR "Unsupported compiler")
@ -69,8 +67,8 @@ else()
endif() endif()
# define the install directory for miscellaneous files # define the install directory for miscellaneous files
if(WINDOWS) if(SFML_OS_WINDOWS)
set(INSTALL_MISC_DIR .) set(INSTALL_MISC_DIR .)
elseif(UNIX) elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
set(INSTALL_MISC_DIR share/SFML) set(INSTALL_MISC_DIR share/SFML)
endif() endif()

View File

@ -10,12 +10,12 @@ include(CMakeParseArguments)
# pre-link dependencies, we just "link" them so that the SFML samples can compile # pre-link dependencies, we just "link" them so that the SFML samples can compile
# out-of-the-box (CMake forwards the dependencies automatically) # out-of-the-box (CMake forwards the dependencies automatically)
macro(sfml_static_add_libraries target) macro(sfml_static_add_libraries target)
if(WINDOWS AND COMPILER_GCC) if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
# Windows - gcc # Windows - gcc
foreach(lib ${ARGN}) foreach(lib ${ARGN})
if(NOT ${lib} MATCHES ".*/.*") if(NOT ${lib} MATCHES ".*/.*")
string(REGEX REPLACE "(.*)/bin/.*\\.exe" "\\1" STANDARD_LIBS_PATH "${CMAKE_CXX_COMPILER}") string(REGEX REPLACE "(.*)/bin/.*\\.exe" "\\1" STANDARD_LIBS_PATH "${CMAKE_CXX_COMPILER}")
if(COMPILER_GCC_W64) if(SFML_COMPILER_GCC_W64)
set(lib "${STANDARD_LIBS_PATH}/${GCC_MACHINE}/lib/lib${lib}.a") set(lib "${STANDARD_LIBS_PATH}/${GCC_MACHINE}/lib/lib${lib}.a")
else() else()
set(lib "${STANDARD_LIBS_PATH}/lib/lib${lib}.a") set(lib "${STANDARD_LIBS_PATH}/lib/lib${lib}.a")
@ -30,14 +30,14 @@ macro(sfml_static_add_libraries target)
COMMAND del *.o /f /q COMMAND del *.o /f /q
VERBATIM) VERBATIM)
endforeach() endforeach()
elseif(MSVC) elseif(SFML_COMPILER_MSVC)
# Visual C++ # Visual C++
set(LIBRARIES "") set(LIBRARIES "")
foreach(lib ${ARGN}) foreach(lib ${ARGN})
if(NOT ${lib} MATCHES ".*\\.lib") if(NOT ${lib} MATCHES ".*\\.lib")
set(lib ${lib}.lib) set(lib ${lib}.lib)
endif() endif()
if(MSVC_IDE AND MSVC_VERSION LESS 2010) if(MSVC_IDE AND SFML_MSVC_VERSION LESS 2010)
# for Visual Studio projects < 2010, we must add double quotes # for Visual Studio projects < 2010, we must add double quotes
# around paths because they may contain spaces # around paths because they may contain spaces
set(LIBRARIES "${LIBRARIES} &quot\\;${lib}&quot\\;") set(LIBRARIES "${LIBRARIES} &quot\\;${lib}&quot\\;")
@ -72,14 +72,14 @@ macro(sfml_add_library target)
# adjust the output file prefix/suffix to match our conventions # adjust the output file prefix/suffix to match our conventions
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
if(WINDOWS) if(SFML_OS_WINDOWS)
# include the major version number in Windows shared library names (but not import library names) # 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 DEBUG_POSTFIX -d)
set_target_properties(${target} PROPERTIES SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}") set_target_properties(${target} PROPERTIES SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
else() else()
set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d) set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
endif() 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, # on Windows/gcc get rid of "lib" prefix for shared libraries,
# and transform the ".dll.a" suffix into ".a" for import libraries # and transform the ".dll.a" suffix into ".a" for import libraries
set_target_properties(${target} PROPERTIES PREFIX "") set_target_properties(${target} PROPERTIES PREFIX "")
@ -99,15 +99,15 @@ macro(sfml_add_library target)
set_target_properties(${target} PROPERTIES FOLDER "SFML") set_target_properties(${target} PROPERTIES FOLDER "SFML")
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled # for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
if(WINDOWS AND COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS) if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS)
if(NOT GCC_VERSION VERSION_LESS "4") if(NOT SFML_GCC_VERSION VERSION_LESS "4")
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++") set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
endif() endif()
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) # (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) set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
endif() endif()
@ -117,7 +117,7 @@ macro(sfml_add_library target)
endif() endif()
# build frameworks or dylibs # build frameworks or dylibs
if(MACOSX AND BUILD_SHARED_LIBS) if(SFML_OS_MACOSX AND BUILD_SHARED_LIBS)
if(SFML_BUILD_FRAMEWORKS) if(SFML_BUILD_FRAMEWORKS)
# adapt target to build frameworks instead of dylibs # adapt target to build frameworks instead of dylibs
set_target_properties(${target} PROPERTIES set_target_properties(${target} PROPERTIES
@ -168,7 +168,7 @@ macro(sfml_add_example target)
source_group("" FILES ${THIS_SOURCES}) source_group("" FILES ${THIS_SOURCES})
# create the target # create the target
if(THIS_GUI_APP AND WINDOWS) if(THIS_GUI_APP AND SFML_OS_WINDOWS)
add_executable(${target} WIN32 ${THIS_SOURCES}) add_executable(${target} WIN32 ${THIS_SOURCES})
target_link_libraries(${target} sfml-main) target_link_libraries(${target} sfml-main)
else() else()
@ -182,8 +182,8 @@ macro(sfml_add_example target)
set_target_properties(${target} PROPERTIES FOLDER "Examples") set_target_properties(${target} PROPERTIES FOLDER "Examples")
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled # for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
if(WINDOWS AND COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS) if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS)
if(NOT GCC_VERSION VERSION_LESS "4") if(NOT SFML_GCC_VERSION VERSION_LESS "4")
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++") set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
endif() endif()
endif() endif()

View File

@ -1,6 +1,6 @@
# find doxygen # find doxygen
if(MACOSX) if(SFML_OS_MACOSX)
# Add some path to search doxygen in more directories. # Add some path to search doxygen in more directories.
set(ADDITIONAL_PATHS set(ADDITIONAL_PATHS
/Developer/Applications/Doxygen.app/Contents/Resources /Developer/Applications/Doxygen.app/Contents/Resources
@ -20,7 +20,7 @@ set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR})
set(DOXYGEN_OUTPUT_DIR ${PROJECT_BINARY_DIR}/doc) set(DOXYGEN_OUTPUT_DIR ${PROJECT_BINARY_DIR}/doc)
# see if we can generate the CHM documentation # 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 # if HHC is found, we can generate the CHM (compressed HTML) output
find_program(DOXYGEN_HHC_PROGRAM find_program(DOXYGEN_HHC_PROGRAM
NAMES hhc.exe NAMES hhc.exe

View File

@ -9,10 +9,10 @@ add_subdirectory(sound)
add_subdirectory(sound_capture) add_subdirectory(sound_capture)
add_subdirectory(voip) add_subdirectory(voip)
add_subdirectory(window) add_subdirectory(window)
if(WINDOWS) if(SFML_OS_WINDOWS)
add_subdirectory(win32) add_subdirectory(win32)
elseif(LINUX) elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
add_subdirectory(X11) add_subdirectory(X11)
elseif(MACOSX) elseif(SFML_OS_MACOSX)
add_subdirectory(cocoa) add_subdirectory(cocoa)
endif() endif()

View File

@ -31,10 +31,10 @@ set(SRC
source_group("" FILES ${SRC}) source_group("" FILES ${SRC})
# let CMake know about our additional audio libraries paths (on Windows and OSX) # let CMake know about our additional audio libraries paths (on Windows and OSX)
if(WINDOWS) if(SFML_OS_WINDOWS)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/AL") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/AL")
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libsndfile/windows") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libsndfile/windows")
elseif (MACOSX) elseif(SFML_OS_MACOSX)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libsndfile/osx") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libsndfile/osx")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-osx/Frameworks") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-osx/Frameworks")
endif() endif()

View File

@ -3,9 +3,9 @@
include(${PROJECT_SOURCE_DIR}/cmake/Macros.cmake) include(${PROJECT_SOURCE_DIR}/cmake/Macros.cmake)
# let CMake know about our additional libraries paths (on Windows and OS X) # let CMake know about our additional libraries paths (on Windows and OS X)
if (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(COMPILER_GCC) if(SFML_COMPILER_GCC)
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,14 +13,14 @@ if (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(COMPILER_MSVC) elseif(SFML_COMPILER_MSVC)
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")
elseif(ARCH_64BITS) elseif(ARCH_64BITS)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc/x64") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-msvc/x64")
endif() endif()
endif() endif()
elseif(MACOSX) elseif(SFML_OS_MACOSX)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-osx/lib/") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-osx/lib/")
endif() endif()
@ -40,6 +40,6 @@ add_subdirectory(Window)
add_subdirectory(Network) add_subdirectory(Network)
add_subdirectory(Graphics) add_subdirectory(Graphics)
add_subdirectory(Audio) add_subdirectory(Audio)
if(WINDOWS) if(SFML_OS_WINDOWS)
add_subdirectory(Main) add_subdirectory(Main)
endif() endif()

View File

@ -84,14 +84,14 @@ set(STB_SRC
source_group("stb_image" FILES ${STB_SRC}) source_group("stb_image" FILES ${STB_SRC})
# let CMake know about our additional graphics libraries paths (on Windows and OSX) # let CMake know about our additional graphics libraries paths (on Windows and OSX)
if(WINDOWS OR MACOSX) if(SFML_OS_WINDOWS OR SFML_OS_MACOSX)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/jpeg") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/jpeg")
endif() endif()
if(WINDOWS) if(SFML_OS_WINDOWS)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libfreetype/windows") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libfreetype/windows")
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libfreetype/windows/freetype") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libfreetype/windows/freetype")
elseif(MACOSX) elseif(SFML_OS_MACOSX)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libfreetype/osx") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libfreetype/osx")
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libfreetype/osx/freetype2") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/libfreetype/osx/freetype2")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-osx/Frameworks") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-osx/Frameworks")
@ -102,7 +102,7 @@ find_package(OpenGL REQUIRED)
find_package(Freetype REQUIRED) find_package(Freetype REQUIRED)
find_package(GLEW REQUIRED) find_package(GLEW REQUIRED)
find_package(JPEG REQUIRED) find_package(JPEG REQUIRED)
if(LINUX) if(SFML_OS_LINUX)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
endif() endif()
@ -114,7 +114,7 @@ include_directories(${FREETYPE_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH} ${JPEG_INCLUDE
set(GRAPHICS_EXT_LIBS ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY}) set(GRAPHICS_EXT_LIBS ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY})
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
set(GRAPHICS_EXT_LIBS ${GRAPHICS_EXT_LIBS} ${OPENGL_gl_LIBRARY}) set(GRAPHICS_EXT_LIBS ${GRAPHICS_EXT_LIBS} ${OPENGL_gl_LIBRARY})
if(LINUX) if(SFML_OS_LINUX)
set(GRAPHICS_EXT_LIBS ${GRAPHICS_EXT_LIBS} ${X11_LIBRARIES}) set(GRAPHICS_EXT_LIBS ${GRAPHICS_EXT_LIBS} ${X11_LIBRARIES})
endif() endif()
endif() endif()
@ -124,7 +124,7 @@ add_definitions(-DGLEW_STATIC -DSTBI_FAILURE_USERMSG)
# ImageLoader.cpp must be compiled with the -fno-strict-aliasing # ImageLoader.cpp must be compiled with the -fno-strict-aliasing
# when gcc is used; otherwise saving PNGs may crash in stb_image_write # when gcc is used; otherwise saving PNGs may crash in stb_image_write
if(COMPILER_GCC) if(SFML_OS_COMPILER_GCC)
set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing) set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
endif() endif()

View File

@ -28,7 +28,7 @@ set(SRC
) )
# add platform specific sources # add platform specific sources
if(WINDOWS) if(SFML_OS_WINDOWS)
set(SRC set(SRC
${SRC} ${SRC}
${SRCROOT}/Win32/SocketImpl.cpp ${SRCROOT}/Win32/SocketImpl.cpp
@ -46,7 +46,7 @@ source_group("" FILES ${SRC})
# build the list of external libraries to link # build the list of external libraries to link
set(NETWORK_EXT_LIBS) set(NETWORK_EXT_LIBS)
if(WINDOWS) if(SFML_OS_WINDOWS)
set(NETWORK_EXT_LIBS ${NETWORK_EXT_LIBS} ws2_32) set(NETWORK_EXT_LIBS ${NETWORK_EXT_LIBS} ws2_32)
endif() endif()

View File

@ -39,7 +39,7 @@ set(SRC
source_group("" FILES ${SRC}) source_group("" FILES ${SRC})
# add platform specific sources # add platform specific sources
if(WINDOWS) if(SFML_OS_WINDOWS)
set(PLATFORM_SRC set(PLATFORM_SRC
${SRCROOT}/Win32/ClockImpl.cpp ${SRCROOT}/Win32/ClockImpl.cpp
${SRCROOT}/Win32/ClockImpl.hpp ${SRCROOT}/Win32/ClockImpl.hpp
@ -71,13 +71,13 @@ endif()
# build the list of external libraries to link # build the list of external libraries to link
set(SYSTEM_EXT_LIBS) set(SYSTEM_EXT_LIBS)
if(UNIX) if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} pthread) set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} pthread)
endif() endif()
if(LINUX) if(SFML_OS_LINUX)
set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} rt) set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} rt)
endif() endif()
if(WINDOWS) if(SFML_OS_WINDOWS)
set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} winmm) set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} winmm)
endif() endif()

View File

@ -36,7 +36,7 @@ set(SRC
source_group("" FILES ${SRC}) source_group("" FILES ${SRC})
# add platform specific sources # add platform specific sources
if(WINDOWS) if(SFML_OS_WINDOWS)
set(PLATFORM_SRC set(PLATFORM_SRC
${SRCROOT}/Win32/WglContext.cpp ${SRCROOT}/Win32/WglContext.cpp
${SRCROOT}/Win32/WglContext.hpp ${SRCROOT}/Win32/WglContext.hpp
@ -52,7 +52,7 @@ if(WINDOWS)
# make sure that we use the Unicode version of the Win API functions # make sure that we use the Unicode version of the Win API functions
add_definitions(-DUNICODE) add_definitions(-DUNICODE)
elseif(UNIX) elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
set(PLATFORM_SRC set(PLATFORM_SRC
${SRCROOT}/Unix/Display.cpp ${SRCROOT}/Unix/Display.cpp
${SRCROOT}/Unix/Display.hpp ${SRCROOT}/Unix/Display.hpp
@ -64,13 +64,13 @@ elseif(UNIX)
${SRCROOT}/Unix/WindowImplX11.cpp ${SRCROOT}/Unix/WindowImplX11.cpp
${SRCROOT}/Unix/WindowImplX11.hpp ${SRCROOT}/Unix/WindowImplX11.hpp
) )
if(LINUX) if(SFML_OS_LINUX)
set(PLATFORM_SRC set(PLATFORM_SRC
${PLATFORM_SRC} ${PLATFORM_SRC}
${SRCROOT}/Unix/JoystickImpl.cpp ${SRCROOT}/Unix/JoystickImpl.cpp
${SRCROOT}/Unix/JoystickImpl.hpp ${SRCROOT}/Unix/JoystickImpl.hpp
) )
elseif(FREEBSD) elseif(SFML_OS_FREEBSD)
set(PLATFORM_SRC set(PLATFORM_SRC
${PLATFORM_SRC} ${PLATFORM_SRC}
${SRCROOT}/FreeBSD/JoystickImpl.cpp ${SRCROOT}/FreeBSD/JoystickImpl.cpp
@ -78,7 +78,7 @@ elseif(UNIX)
) )
endif() endif()
source_group("unix" FILES ${PLATFORM_SRC}) source_group("unix" FILES ${PLATFORM_SRC})
elseif(MACOSX) elseif(SFML_OS_MACOSX)
set(PLATFORM_SRC set(PLATFORM_SRC
${SRCROOT}/OSX/cpp_objc_conversion.h ${SRCROOT}/OSX/cpp_objc_conversion.h
${SRCROOT}/OSX/cpp_objc_conversion.mm ${SRCROOT}/OSX/cpp_objc_conversion.mm
@ -123,7 +123,7 @@ endif()
# find external libraries # find external libraries
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
if(LINUX) if(SFML_OS_LINUX)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
if(NOT X11_Xrandr_FOUND) if(NOT X11_Xrandr_FOUND)
message(FATAL_ERROR "Xrandr library not found") message(FATAL_ERROR "Xrandr library not found")
@ -133,14 +133,14 @@ endif()
# build the list of external libraries to link # build the list of external libraries to link
set(WINDOW_EXT_LIBS ${OPENGL_gl_LIBRARY}) set(WINDOW_EXT_LIBS ${OPENGL_gl_LIBRARY})
if(WINDOWS) if(SFML_OS_WINDOWS)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} winmm gdi32) set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} winmm gdi32)
elseif(LINUX) elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} ${X11_X11_LIB} ${X11_Xrandr_LIB}) set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} ${X11_X11_LIB} ${X11_Xrandr_LIB})
if(FREEBSD) if(SFML_OS_FREEBSD)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} usbhid) set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} usbhid)
endif() endif()
elseif(MACOSX) elseif(SFML_OS_MACOSX)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} "-framework Foundation -framework AppKit -framework IOKit -framework Carbon") set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} "-framework Foundation -framework AppKit -framework IOKit -framework Carbon")
endif() endif()