summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt134
-rw-r--r--cmake/Options.cmake6
-rw-r--r--src/CMakeLists.txt11
-rw-r--r--src/script/CMakeLists.txt4
-rw-r--r--src/script/api/CMakeLists.txt4
-rw-r--r--src/strgen/CMakeLists.txt4
6 files changed, 98 insertions, 65 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8f7aa071..1a0dd5b75 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,78 @@ set_directory_options()
include(Static)
set_static_if_needed()
+if(MSVC)
+ # C++17 for MSVC
+ set(CMAKE_CXX_STANDARD 17)
+else()
+ # C++11 for all other targets
+ set(CMAKE_CXX_STANDARD 11)
+endif()
+
+set(CMAKE_CXX_STANDARD_REQUIRED YES)
+set(CMAKE_CXX_EXTENSIONS NO)
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
+
+# An empty target for the tools
+add_custom_target(tools)
+
+include(Endian)
+add_endian_definition()
+
+include(CompileFlags)
+compile_flags()
+
+if(APPLE OR UNIX)
+ add_definitions(-DUNIX)
+endif()
+
+if(UNIX)
+ find_package(Doxygen)
+endif()
+
+list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/rev.cpp")
+if(WIN32)
+ list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/ottdres.rc")
+endif()
+
+# Generate a target to determine version, which is execute every 'make' run
+add_custom_target(find_version
+ ${CMAKE_COMMAND}
+ -DFIND_VERSION_BINARY_DIR=${CMAKE_BINARY_DIR}/generated
+ -DCPACK_BINARY_DIR=${CMAKE_BINARY_DIR}
+ -P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ BYPRODUCTS ${GENERATED_SOURCE_FILES}
+)
+
+# Documentation
+if(DOXYGEN_EXECUTABLE)
+ add_custom_target(docs)
+ add_custom_target(docs_source
+ ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs
+ COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Generating documentation for source"
+ )
+ add_dependencies(docs_source
+ find_version
+ )
+ add_dependencies(docs
+ docs_source
+ )
+endif()
+
+include(AddCustomXXXTimestamp)
+
+if(OPTION_TOOLS_ONLY)
+ if(HOST_BINARY_DIR)
+ unset(HOST_BINARY_DIR CACHE)
+ endif()
+ add_subdirectory(${CMAKE_SOURCE_DIR}/src)
+ return()
+endif()
+
# Prefer -pthread over -lpthread, which is often the better option of the two.
set(CMAKE_THREAD_PREFER_PTHREAD YES)
# Make sure we have Threads available.
@@ -72,10 +144,6 @@ find_package(Xaudio2)
find_package(Grfcodec)
-if(UNIX)
- find_package(Doxygen)
-endif()
-
# IPO is only properly supported from CMake 3.9. Despite the fact we are
# CMake 3.5, still enable IPO if we detect we are 3.9+.
if(POLICY CMP0069)
@@ -103,57 +171,7 @@ if(APPLE)
endif()
endif()
-if(MSVC)
- # C++17 for MSVC
- set(CMAKE_CXX_STANDARD 17)
-else()
- # C++11 for all other targets
- set(CMAKE_CXX_STANDARD 11)
-endif()
-
-set(CMAKE_CXX_STANDARD_REQUIRED YES)
-set(CMAKE_CXX_EXTENSIONS NO)
-
-set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
-
-list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/rev.cpp")
-if(WIN32)
- list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/ottdres.rc")
-endif()
-
-# Generate a target to determine version, which is execute every 'make' run
-add_custom_target(find_version
- ${CMAKE_COMMAND}
- -DFIND_VERSION_BINARY_DIR=${CMAKE_BINARY_DIR}/generated
- -DCPACK_BINARY_DIR=${CMAKE_BINARY_DIR}
- -P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- BYPRODUCTS ${GENERATED_SOURCE_FILES}
-)
-
-# An empty target for the tools
-add_custom_target(tools)
-
-# Documentation
-if(DOXYGEN_EXECUTABLE)
- add_custom_target(docs)
- add_custom_target(docs_source
- ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs
- COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMENT "Generating documentation for source"
- )
- add_dependencies(docs_source
- find_version
- )
- add_dependencies(docs
- docs_source
- )
-endif()
-
include(SourceList)
-include(Endian)
-add_endian_definition()
# Needed by rev.cpp
include_directories(${CMAKE_SOURCE_DIR}/src)
@@ -162,14 +180,10 @@ include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/squirrel/include)
include(MSVCFilters)
-include(CompileFlags)
-compile_flags()
-
add_executable(openttd WIN32 ${GENERATED_SOURCE_FILES})
set_target_properties(openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}")
# All other files are added via target_sources()
-include(AddCustomXXXTimestamp)
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
add_subdirectory(${CMAKE_SOURCE_DIR}/media/baseset)
@@ -192,10 +206,6 @@ endif()
set_target_properties(openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
process_compile_flags()
-if(APPLE OR UNIX)
- add_definitions(-DUNIX)
-endif()
-
include(LinkPackage)
link_package(PNG TARGET PNG::PNG ENCOURAGED)
link_package(ZLIB TARGET ZLIB::ZLIB ENCOURAGED)
diff --git a/cmake/Options.cmake b/cmake/Options.cmake
index 005bb19ca..977d54f06 100644
--- a/cmake/Options.cmake
+++ b/cmake/Options.cmake
@@ -57,6 +57,12 @@ function(set_options)
option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" ON)
option(OPTION_USE_THREADS "Use threads" ON)
option(OPTION_USE_NSIS "Use NSIS to create windows installer; enable only for stable releases" OFF)
+ option(OPTION_TOOLS_ONLY "Build only tools target" OFF)
+ option(OPTION_DOCS_ONLY "Build only docs target" OFF)
+
+ if (OPTION_DOCS_ONLY)
+ set(OPTION_TOOLS_ONLY ON PARENT_SCOPE)
+ endif()
endfunction()
# Show the values of the generic options.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0a0ac406a..bbe66b764 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,3 +1,11 @@
+add_subdirectory(script)
+add_subdirectory(settingsgen)
+add_subdirectory(strgen)
+
+if(OPTION_TOOLS_ONLY)
+ return()
+endif()
+
add_subdirectory(3rdparty)
add_subdirectory(ai)
add_subdirectory(blitter)
@@ -11,11 +19,8 @@ add_subdirectory(network)
add_subdirectory(os)
add_subdirectory(pathfinder)
add_subdirectory(saveload)
-add_subdirectory(script)
-add_subdirectory(settingsgen)
add_subdirectory(sound)
add_subdirectory(spriteloader)
-add_subdirectory(strgen)
add_subdirectory(table)
add_subdirectory(video)
add_subdirectory(widgets)
diff --git a/src/script/CMakeLists.txt b/src/script/CMakeLists.txt
index e5915332c..f4b87dc3b 100644
--- a/src/script/CMakeLists.txt
+++ b/src/script/CMakeLists.txt
@@ -1,5 +1,9 @@
add_subdirectory(api)
+if(OPTION_TOOLS_ONLY)
+ return()
+endif()
+
add_files(
script_config.cpp
script_config.hpp
diff --git a/src/script/api/CMakeLists.txt b/src/script/api/CMakeLists.txt
index 9bc4183f1..c21707d43 100644
--- a/src/script/api/CMakeLists.txt
+++ b/src/script/api/CMakeLists.txt
@@ -131,6 +131,10 @@ foreach(API "ai;AI" "game;GS" "template;Template")
)
endforeach()
+if(OPTION_TOOLS_ONLY)
+ return()
+endif()
+
add_library(openttd::script_api ALIAS script_api)
diff --git a/src/strgen/CMakeLists.txt b/src/strgen/CMakeLists.txt
index c638b5c6e..08c122335 100644
--- a/src/strgen/CMakeLists.txt
+++ b/src/strgen/CMakeLists.txt
@@ -22,6 +22,10 @@ if (NOT HOST_BINARY_DIR)
add_dependencies(tools strgen)
endif()
+if(OPTION_TOOLS_ONLY)
+ return()
+endif()
+
# Source Files
add_files(strgen_base.cpp)