mirror of
https://github.com/SFML/SFML.git
synced 2024-12-01 07:41:05 +08:00
Added macros to define the SFML version in Config.hpp
Improved FindSFML.cmake to check the version git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1724 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
86ec781e81
commit
166de04854
@ -26,6 +26,13 @@
|
|||||||
#define SFML_CONFIG_H
|
#define SFML_CONFIG_H
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Define the CSFML version
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
#define CSFML_VERSION_MAJOR 2
|
||||||
|
#define CSFML_VERSION_MINOR 0
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Identify the operating system
|
// Identify the operating system
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
#
|
#
|
||||||
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
|
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
|
||||||
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
|
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
|
||||||
|
#
|
||||||
|
# If SFML is not installed in a standard path, you can use the SFMLDIR CMake variable
|
||||||
|
# to tell CMake where SFML is.
|
||||||
|
|
||||||
# deduce the libraries suffix from the options
|
# deduce the libraries suffix from the options
|
||||||
set(FIND_SFML_LIB_SUFFIX "")
|
set(FIND_SFML_LIB_SUFFIX "")
|
||||||
@ -30,6 +33,32 @@ find_path(SFML_INCLUDE_DIR SFML/Config.hpp
|
|||||||
/opt/
|
/opt/
|
||||||
${SFMLDIR})
|
${SFMLDIR})
|
||||||
|
|
||||||
|
# check the version number
|
||||||
|
set(SFML_VERSION_OK TRUE)
|
||||||
|
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
|
||||||
|
# extract the major and minor version numbers from SFML/Config.hpp
|
||||||
|
FILE(READ "${SFML_INCLUDE_DIR}/SFML/Config.hpp" SFML_CONFIG_HPP_CONTENTS)
|
||||||
|
STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
|
||||||
|
STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
|
||||||
|
math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10 + ${SFML_FIND_VERSION_MINOR}")
|
||||||
|
|
||||||
|
# if we could extract them, compare with the requested version number
|
||||||
|
if (SFML_VERSION_MAJOR)
|
||||||
|
# transform version numbers to an integer
|
||||||
|
math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10 + ${SFML_VERSION_MINOR}")
|
||||||
|
|
||||||
|
# compare them
|
||||||
|
if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
|
||||||
|
set(SFML_VERSION_OK FALSE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# SFML version is < 2.0
|
||||||
|
if (SFML_REQUESTED_VERSION GREATER 19)
|
||||||
|
set(SFML_VERSION_OK FALSE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# find the requested components
|
# find the requested components
|
||||||
set(FIND_SFML_LIB_PATHS ~/Library/Frameworks
|
set(FIND_SFML_LIB_PATHS ~/Library/Frameworks
|
||||||
/Library/Frameworks
|
/Library/Frameworks
|
||||||
@ -62,7 +91,12 @@ foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
|
|||||||
set(SFML_LIBRARIES ${SFML_LIBRARIES} ${${FIND_SFML_COMPONENT_VAR}})
|
set(SFML_LIBRARIES ${SFML_LIBRARIES} ${${FIND_SFML_COMPONENT_VAR}})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set SFML_FOUND to TRUE if all listed variables are TRUE
|
if(SFML_FIND_REQUIRED AND NOT SFML_VERSION_OK)
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
message(SEND_ERROR "Bad SFML version (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR})")
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SFML DEFAULT_MSG SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})
|
set(SFML_FOUND FALSE)
|
||||||
MARK_AS_ADVANCED(SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})
|
else()
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set SFML_FOUND to TRUE if all listed variables are TRUE
|
||||||
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SFML DEFAULT_MSG SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})
|
||||||
|
MARK_AS_ADVANCED(SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})
|
||||||
|
endif()
|
||||||
|
@ -26,6 +26,13 @@
|
|||||||
#define SFML_CONFIG_HPP
|
#define SFML_CONFIG_HPP
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Define the SFML version
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
#define SFML_VERSION_MAJOR 2
|
||||||
|
#define SFML_VERSION_MINOR 0
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Identify the operating system
|
// Identify the operating system
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user