Use proper cmake detection of features.
This attempts to organize all needed items and places appropriate defines in a single location. Redundant comparisons/defines were removed when noticed. A few caveats, however: * This may be better targeted towards the 5_1_0 branch instead of master right now. * Cmake will run a little slower on configuration/generation now. That's due to the sanity checks it runs. * There are some more checks to be added later, but this should be a solid start. Thanks to the [libical](https://github.com/libical/libical) project for inspiration.
This commit is contained in:
+65
-7
@@ -45,8 +45,72 @@ include("${CMAKE_CURRENT_LIST_DIR}/CMake/SMDefs.cmake")
|
||||
# Put the predefined targets in separate groups.
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
# Checks the standard include directories for c-style headers.
|
||||
# We may use C++ in this project, but the check works better with plain C headers.
|
||||
include(CheckIncludeFiles)
|
||||
check_include_files(math.h HAVE_MATH_H)
|
||||
check_include_files(alloca.h HAVE_ALLOCA_H)
|
||||
check_include_files(dirent.h HAVE_DIRENT_H)
|
||||
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_files(stdint.h HAVE_STDINT_H)
|
||||
check_include_files(endian.h HAVE_ENDIAN_H)
|
||||
check_include_files(sys/endian.h HAVE_SYS_ENDIAN_H)
|
||||
check_include_files(machine/endian.h HAVE_MACHINE_ENDIAN_H)
|
||||
check_include_files(sys/param.h HAS_SYS_PARAM_H)
|
||||
check_include_files(sys/utsname.h HAS_SYS_UTSNAME_H)
|
||||
check_include_files(fcntl.h HAVE_FCNTL_H)
|
||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||
|
||||
include(CheckFunctionExists)
|
||||
include(CheckSymbolExists)
|
||||
if (WIN32 AND MSVC)
|
||||
check_function_exists(_mkdir HAVE__MKDIR)
|
||||
check_function_exists(_snprintf HAVE__SNPRINTF)
|
||||
check_symbol_exists(powf math.h HAVE_POWF)
|
||||
check_symbol_exists(sqrtf math.h HAVE_SQRTF)
|
||||
check_symbol_exists(sinf math.h HAVE_SINF)
|
||||
check_symbol_exists(tanf math.h HAVE_TANF)
|
||||
check_symbol_exists(cosf math.h HAVE_COSF)
|
||||
check_symbol_exists(acosf math.h HAVE_ACOSF)
|
||||
else()
|
||||
check_function_exists(mkdir HAVE_MKDIR)
|
||||
check_function_exists(snprintf HAVE_SNPRINTF)
|
||||
check_function_exists(powf HAVE_POWF)
|
||||
check_function_exists(sqrtf HAVE_SQRTF)
|
||||
check_function_exists(sinf HAVE_SINF)
|
||||
check_function_exists(tanf HAVE_TANF)
|
||||
check_function_exists(cosf HAVE_COSF)
|
||||
check_function_exists(acosf HAVE_ACOSF)
|
||||
endif()
|
||||
check_function_exists(truncf HAVE_TRUNCF)
|
||||
check_function_exists(roundf HAVE_ROUNDF)
|
||||
check_function_exists(lrintf HAVE_LRINTF)
|
||||
check_function_exists(strtof HAVE_STRTOF)
|
||||
check_symbol_exists(M_PI math.h HAVE_M_PI)
|
||||
|
||||
# Checks to make it easier to work with 32-bit/64-bit builds if required.
|
||||
include(CheckTypeSize)
|
||||
check_type_size(intptr_t SIZEOF_INTPTR_T)
|
||||
check_type_size(pid_t SIZEOF_PID_T)
|
||||
check_type_size(size_t SIZEOF_SIZE_T)
|
||||
check_type_size(ssize_t SIZEOF_SSIZE_T)
|
||||
|
||||
include(TestBigEndian)
|
||||
test_big_endian(BIGENDIAN)
|
||||
if (${BIGENDIAN})
|
||||
set(ENDIAN_BIG 1)
|
||||
else()
|
||||
set(ENDIAN_LITTLE 1)
|
||||
endif()
|
||||
|
||||
if (WITH_VERSION_INFO)
|
||||
set(HAVE_VERSION_INFO 1)
|
||||
endif()
|
||||
|
||||
configure_file("${SM_SRC_DIR}/config.in.hpp" "${SM_SRC_DIR}/generated/config.hpp")
|
||||
|
||||
# Dependencies go here.
|
||||
set(ENDIANNESS "ENDIAN_LITTLE")
|
||||
|
||||
if(WIN32)
|
||||
set(HAS_OGG TRUE)
|
||||
set(HAS_MP3 TRUE)
|
||||
@@ -114,7 +178,6 @@ elseif(MACOSX)
|
||||
MAC_FRAME_QUICKTIME
|
||||
)
|
||||
elseif(LINUX)
|
||||
include(TestBigEndian)
|
||||
include(ExternalProject)
|
||||
|
||||
if(NOT WITH_GPL_LIBS)
|
||||
@@ -321,11 +384,6 @@ elseif(LINUX)
|
||||
message(FATAL_ERROR "GLEW required to compile StepMania.")
|
||||
endif()
|
||||
|
||||
test_big_endian(BIGENDIAN)
|
||||
if (${BIGENDIAN})
|
||||
set(ENDIANNESS "ENDIAN_BIG")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# Define installer based items for cpack.
|
||||
|
||||
Reference in New Issue
Block a user