2012-09-14 20:39:40 +02:00
############################################################################
#
# file : options.cmake
# copyright : (C) 2008 by Mart Kelder, 2010 by J.-P. Meuret
2020-12-31 02:00:49 +01:00
# web : www.speed-dreams.org
2012-09-14 20:39:40 +02:00
# version : $Id$
#
############################################################################
############################################################################
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
############################################################################
# @file CMake configuration options
# @author Mart Kelder, J.-P. Meuret
# @version $Id$
2016-06-03 00:51:09 +02:00
INCLUDE ( CMakeDependentOption )
2012-09-14 20:39:40 +02:00
MACRO ( ADD_SD_COMPILE_OPTIONS )
# This has to be done more than once, because HAVE_CONFIG_H may change.
IF ( HAVE_CONFIG_H )
ADD_DEFINITIONS ( -DHAVE_CONFIG_H )
IF ( IN_SOURCETREE )
SET ( INCLUDE_CANDIDATE ${ SOURCE_DIR } )
ELSE ( IN_SOURCETREE )
SET ( INCLUDE_CANDIDATE "" )
ENDIF ( IN_SOURCETREE )
FIND_PATH ( CONFIGH_INCLUDE_DIR config.h ${ INCLUDE_CANDIDATE } /usr/include /usr/local/include NO_DEFAULT_PATH )
FIND_PATH ( CONFIGH_INCLUDE_DIR config.h ${ INCLUDE_CANDIDATE } /usr/include /usr/local/include )
MARK_AS_ADVANCED ( CONFIGH_INCLUDE_DIR )
IF ( CONFIGH_INCLUDE_DIR )
INCLUDE_DIRECTORIES ( ${ CONFIGH_INCLUDE_DIR } )
ELSE ( CONFIGH_INCLUDE_DIR )
MESSAGE ( FATAL_ERROR "Cannot find config.h header file" )
ENDIF ( CONFIGH_INCLUDE_DIR )
ENDIF ( HAVE_CONFIG_H )
# Build options (do it only once).
IF ( NOT _ALREADY_DONE )
2013-03-24 15:38:12 +01:00
# Default build configuration.
IF ( NOT MSVC )
IF ( NOT CMAKE_BUILD_TYPE )
SET ( CMAKE_BUILD_TYPE "Release" CACHE STRING
" C h o o s e t h e t y p e o f b u i l d , o p t i o n s a r e : D e b u g R e l e a s e R e l W i t h D e b I n f o M i n S i z e R e l . "
F O R C E )
ENDIF ( )
MESSAGE ( STATUS "Build configuration : ${CMAKE_BUILD_TYPE}" )
ENDIF ( NOT MSVC )
2012-09-14 20:39:40 +02:00
# CMake options.
2021-06-16 18:18:54 +02:00
SET ( OPTION_CHECK_CONTENTS false CACHE BOOL "Set to off if you don't want the build to be stopped by missing optional contents folders" )
2012-09-14 20:39:40 +02:00
MARK_AS_ADVANCED ( OPTION_CHECK_CONTENTS )
SET ( OPTION_OFFICIAL_ONLY false CACHE BOOL "Build / install only officially released contents" )
SET ( OPTION_FORCE_DEBUG false CACHE BOOL "Force debug symbols even in Release build (Automatic in Debug builds)" )
SET ( OPTION_TRACE true CACHE BOOL "Enable traces into the console or log file" )
SET ( OPTION_TRACE_LEVEL "5" CACHE STRING "Trace level integer threshold, only if OPTION_TRACE (traces with higher level are not logged ; 0=Fatal, 1=Error, 2=Warning, 3=Info, 4=Trace, 5=Debug, ...)" )
SET ( OPTION_PROFILER false CACHE BOOL "Enable profiler" )
2020-12-31 02:00:49 +01:00
2012-09-14 20:39:40 +02:00
SET ( OPTION_SCHEDULE_SPY false CACHE BOOL "Enable fine grained scheduling spy" )
2020-12-31 02:00:49 +01:00
2012-09-14 20:39:40 +02:00
SET ( OPTION_3RDPARTY_EXPAT true CACHE BOOL "Use 3rd party Expat library rather than bundled TXML" )
2014-07-30 05:19:34 +02:00
SET ( OPTION_3RDPARTY_SQLITE3 false CACHE BOOL "Use SQLite3 as database for record/replay" )
2015-10-17 16:46:49 +02:00
SET ( OPTION_OSGGRAPH true CACHE BOOL "Build OpenScenGraph-based WIP osggraph graphics module" )
2023-04-04 11:19:30 +02:00
SET ( OPTION_TINYGLTF false CACHE BOOL "Use tinygltf library" )
2017-11-12 01:30:20 +01:00
SET ( OPTION_WEBSERVER true CACHE BOOL "Build with WebServer functionality" )
2015-11-23 20:44:40 +01:00
2023-06-26 01:32:36 +02:00
SET ( OPTION_CLIENT_SERVER true CACHE BOOL "Build with Client/Server network architecture" )
2016-10-11 19:35:17 +02:00
2023-06-19 19:30:34 +02:00
SET ( OPTION_PARAM_OPTIMIZER false CACHE BOOL "Build with Parameter Optimizer for Robot development" )
2019-06-04 02:55:22 +02:00
SET ( OPTION_PACKAGING true CACHE BOOL "Enable Packaging for distribution" )
2022-07-19 01:55:34 +02:00
SET ( OPTION_ALL_IN_ONE_PACKAGING false CACHE BOOL "Enable CPack's monolithic PACKAGE" )
2023-11-05 23:25:58 +01:00
SET ( OPTION_PORTABLE_PACKAGING false CACHE BOOL "Enable creation of Portable App as a self-extracting zip" )
2022-06-19 05:01:03 +02:00
SET ( OPTION_TRACKEDITOR true CACHE BOOL "Build the TrackEditor (Requires Java)" )
2015-08-31 02:04:57 +02:00
IF ( APPLE )
# Automatically set OPTION_USE_MACPORTS (at least until someone fixes the regular APPLE build)
MESSAGE ( STATUS "Automatically set OPTION_USE_MACPORTS (at least until someone fixes the regular APPLE build)" )
SET ( OPTION_USE_MACPORTS true CACHE BOOL "Use the MacPorts dependencies" )
ENDIF ( APPLE )
2012-09-14 20:39:40 +02:00
# Enable building with 3rd party SOLID library under Windows, as we ship the binary package,
# but not under Linux, where FreeSolid seems not to be available by default on most distros.
IF ( WIN32 )
SET ( _OPTION_3RDPARTY_SOLID true )
ELSE ( WIN32 )
SET ( _OPTION_3RDPARTY_SOLID false )
ENDIF ( WIN32 )
SET ( OPTION_3RDPARTY_SOLID ${ _OPTION_3RDPARTY_SOLID } CACHE BOOL "Use 3rd party SOLID library rather than simu-bundled one" )
IF ( UNIX )
2020-12-31 02:00:49 +01:00
SET ( OPTION_XRANDR true CACHE BOOL "XrandR" )
2012-09-14 20:39:40 +02:00
SET ( OPTION_GLEXTPROTOTYPES true CACHE BOOL "Enable prototypes in glext.h" )
2022-03-23 16:41:03 +01:00
#SET(OPTION_UNLOAD_SSGGRAPH true CACHE BOOL "If false, never unload ssggraph module (useful on some Linuxes to avoid XOrg crashes)")
2012-09-14 20:39:40 +02:00
ENDIF ( UNIX )
2022-03-23 16:41:03 +01:00
SET ( OPTION_UNLOAD_SSGGRAPH true CACHE BOOL "If false, never unload ssggraph module (useful on some Linuxes to avoid XOrg crashes)" )
2020-12-31 02:00:49 +01:00
2015-08-31 02:04:57 +02:00
IF ( OPTION_USE_MACPORTS )
SET ( CMAKE_MACOSX_RPATH TRUE )
#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET ( CMAKE_PREFIX_PATH "/opt/local" CACHE PATH "Prepended to search path" )
#SET(CMAKE_FIND_ROOT_PATH "/opt/local" CACHE PATH "Prepended to search path")
SET ( CMAKE_FIND_FRAMEWORK LAST )
2015-10-17 16:46:49 +02:00
MESSAGE ( STATUS "Remove the line below to true when OSG works on MacPorts" )
2015-08-31 02:04:57 +02:00
SET ( OPTION_OSGGRAPH false CACHE BOOL "Build OpenScenGraph-based WIP osggraph graphics module" )
ENDIF ( OPTION_USE_MACPORTS )
2020-12-31 02:00:49 +01:00
2012-09-14 20:39:40 +02:00
SET ( OPTION_AUTOVERSION true CACHE BOOL "Enable automatic computation of the version from SVN source tree" )
2020-12-31 02:00:49 +01:00
2012-09-14 20:39:40 +02:00
# Custom 3rdParty location for some Windows builds (standard CMake Find<package> macros
# can't find it, so we needed another solution : see FindCustom3rdParty.cmake).
IF ( MSVC )
SET ( _OPTION_CUSTOM_3RDPARTY true ) # Always needed for MSVC compilers.
ELSEIF ( MINGW )
IF ( CMAKE_GENERATOR STREQUAL "MSYS Makefiles" )
# Not needed with "MSYS Makefiles" generator when using MinGW
# (3rd party libs assumed to be installed in standard location /usr/local).
SET ( _OPTION_CUSTOM_3RDPARTY false )
ELSE ( CMAKE_GENERATOR STREQUAL "MSYS Makefiles" )
# Just as for MSVC builds : special location.
SET ( _OPTION_CUSTOM_3RDPARTY true )
ENDIF ( CMAKE_GENERATOR STREQUAL "MSYS Makefiles" )
ENDIF ( MSVC )
SET ( OPTION_CUSTOM_3RDPARTY ${ _OPTION_CUSTOM_3RDPARTY } CACHE BOOL "Set to ON to use 3rdParty prebuilt API located in <PROJECT_SOURCE_DIR>/../3rdparty" )
MARK_AS_ADVANCED ( OPTION_CUSTOM_3RDPARTY )
# Compiler definitions (needs more comments. Is it needed under Windows ?).
2015-03-18 21:07:06 +01:00
ADD_DEFINITIONS ( -D_DEFAULT_SOURCE -DSHM )
2012-09-14 20:39:40 +02:00
IF ( MSVC )
2020-12-31 02:00:49 +01:00
2012-09-15 16:18:27 +02:00
# Inhibit definition of Macros min(a,b) and max(a,b) for Windows MSVC builds,
# as the names conflict with the template functions from standard template library
ADD_DEFINITIONS ( -DNOMINMAX )
2020-12-31 02:00:49 +01:00
2012-09-14 20:39:40 +02:00
ENDIF ( MSVC )
IF ( OPTION_FORCE_DEBUG )
2012-10-07 15:53:17 +02:00
ADD_DEFINITIONS ( -DSD_DEBUG )
2012-09-14 20:39:40 +02:00
ENDIF ( OPTION_FORCE_DEBUG )
2013-02-16 16:25:07 +01:00
2012-09-14 20:39:40 +02:00
IF ( OPTION_TRACE )
ADD_DEFINITIONS ( -DTRACE_OUT )
ENDIF ( OPTION_TRACE )
2013-02-16 16:25:07 +01:00
2012-09-14 20:39:40 +02:00
IF ( OPTION_TRACE_LEVEL )
ADD_DEFINITIONS ( -DTRACE_LEVEL= ${ OPTION_TRACE_LEVEL } )
ENDIF ( OPTION_TRACE_LEVEL )
2013-02-16 16:25:07 +01:00
2012-09-14 20:39:40 +02:00
IF ( OPTION_XRANDR )
ADD_DEFINITIONS ( -DUSE_RANDR_EXT )
ENDIF ( OPTION_XRANDR )
2013-02-16 16:25:07 +01:00
2012-09-14 20:39:40 +02:00
IF ( OPTION_PROFILER )
ADD_DEFINITIONS ( -DPROFILER )
ENDIF ( OPTION_PROFILER )
2013-02-16 16:25:07 +01:00
2012-09-14 20:39:40 +02:00
IF ( OPTION_SCHEDULE_SPY )
ADD_DEFINITIONS ( -DSCHEDULE_SPY )
ENDIF ( OPTION_SCHEDULE_SPY )
2020-12-31 02:00:49 +01:00
2012-09-14 20:39:40 +02:00
IF ( OPTION_3RDPARTY_EXPAT )
ADD_DEFINITIONS ( -DTHIRD_PARTY_EXPAT )
ENDIF ( OPTION_3RDPARTY_EXPAT )
2012-11-11 16:38:27 +01:00
2014-07-30 05:19:34 +02:00
IF ( OPTION_3RDPARTY_SQLITE3 )
ADD_DEFINITIONS ( -DTHIRD_PARTY_SQLITE3 )
ENDIF ( OPTION_3RDPARTY_SQLITE3 )
2012-09-14 20:39:40 +02:00
IF ( OPTION_3RDPARTY_SOLID )
ADD_DEFINITIONS ( -DTHIRD_PARTY_SOLID )
ENDIF ( OPTION_3RDPARTY_SOLID )
2020-12-31 02:00:49 +01:00
2012-09-14 20:39:40 +02:00
IF ( OPTION_GLEXTPROTOTYPES )
ADD_DEFINITIONS ( -DGL_GLEXT_PROTOTYPES )
ENDIF ( OPTION_GLEXTPROTOTYPES )
IF ( OPTION_UNLOAD_SSGGRAPH )
ADD_DEFINITIONS ( -DUNLOAD_SSGGRAPH )
ENDIF ( OPTION_UNLOAD_SSGGRAPH )
2023-04-06 10:14:22 +02:00
IF ( OPTION_TINYGLTF )
ADD_DEFINITIONS ( -DTINYGLTF )
ENDIF ( OPTION_TINYGLTF )
2015-11-23 20:44:40 +01:00
IF ( OPTION_WEBSERVER )
ADD_DEFINITIONS ( -DWEBSERVER )
ENDIF ( OPTION_WEBSERVER )
2016-10-11 19:35:17 +02:00
IF ( OPTION_CLIENT_SERVER )
ADD_DEFINITIONS ( -DCLIENT_SERVER )
ENDIF ( OPTION_CLIENT_SERVER )
2015-08-31 02:04:57 +02:00
IF ( OPTION_USE_MACPORTS )
ADD_DEFINITIONS ( -DUSE_MACPORTS )
ENDIF ( OPTION_USE_MACPORTS )
2012-09-14 20:39:40 +02:00
# Define for code that needs Torcs backward compatibility
ADD_DEFINITIONS ( -DSPEED_DREAMS )
2020-12-31 02:00:49 +01:00
2012-09-14 20:39:40 +02:00
ENDIF ( NOT _ALREADY_DONE )
# Compile options
IF ( NOT _ALREADY_DONE )
# GCC warnings (at least for the 4.x series, there are none by default).
IF ( CMAKE_COMPILER_IS_GNUCXX )
2013-02-22 19:02:47 +01:00
# Add useful warnings / checks.
SET ( _SD_WOPTS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers" )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_SD_WOPTS}" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_SD_WOPTS}" )
# MSVC warnings (default warning level 3 is not exactly what we want).
ELSEIF ( MSVC )
# Suppress bothering MSVC warnings and add useful warnings / checks.
SET ( _SD_WOPTS "/W4" ) # Better warning level (default seems to be 3).
# Level 3 useless/boring warnings.
SET ( _SD_WOPTS "${_SD_WOPTS} /wd4251" ) # class XXX needs a DLL interface
SET ( _SD_WOPTS "${_SD_WOPTS} /wd4996" ) # std::_Copy_opt disaproved because unsafe
# Level 4 useless/boring warnings.
SET ( _SD_WOPTS "${_SD_WOPTS} /wd4100" ) # unreferenced formal parameter
SET ( _SD_WOPTS "${_SD_WOPTS} /wd4127" ) # conditional expression is constant
SET ( _SD_WOPTS "${_SD_WOPTS} /wd4201" ) # nonstandard extension used : nameless struct/union
SET ( _SD_WOPTS "${_SD_WOPTS} /wd4706" ) # assignment within conditional expression
# Other useless warnings.
2020-12-31 02:00:49 +01:00
ADD_DEFINITIONS ( -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
2013-02-22 19:02:47 +01:00
- D _ C R T _ N O _ D E P R E C A T E - D _ S C L _ S E C U R E _ N O _ W A R N I N G S )
2020-12-31 02:00:49 +01:00
2013-02-22 19:02:47 +01:00
# That's all.
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_SD_WOPTS}" )
SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_SD_WOPTS}" )
2012-09-14 20:39:40 +02:00
ENDIF ( CMAKE_COMPILER_IS_GNUCXX )
ENDIF ( NOT _ALREADY_DONE )
2013-02-16 18:29:09 +01:00
ENDMACRO ( ADD_SD_COMPILE_OPTIONS )