2023-08-14 18:25:26 +01:00
|
|
|
function(_add_files_tgt tgt)
|
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 10:57:55 +01:00
|
|
|
cmake_parse_arguments(PARAM "" "" "CONDITION" ${ARGN})
|
|
|
|
set(PARAM_FILES "${PARAM_UNPARSED_ARGUMENTS}")
|
|
|
|
|
2020-09-25 12:55:25 +01:00
|
|
|
if(PARAM_CONDITION)
|
|
|
|
if(NOT (${PARAM_CONDITION}))
|
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 10:57:55 +01:00
|
|
|
return()
|
2020-09-25 12:55:25 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 10:57:55 +01:00
|
|
|
|
|
|
|
foreach(FILE IN LISTS PARAM_FILES)
|
2023-08-14 18:26:43 +01:00
|
|
|
# Some IDEs are not happy with duplicated filenames, so we detect that before adding the file.
|
|
|
|
get_target_property(${tgt}_FILES ${tgt} SOURCES)
|
|
|
|
if(${tgt}_FILES MATCHES "/${FILE}(;|$)")
|
|
|
|
string(REGEX REPLACE "(^|.+;)([^;]+/${FILE})(;.+|$)" "\\2" RES "${${tgt}_FILES}")
|
|
|
|
# Ignore header files duplicates in 3rdparty.
|
|
|
|
if(NOT (${FILE} MATCHES "\.h" AND (${RES} MATCHES "3rdparty" OR ${CMAKE_CURRENT_SOURCE_DIR} MATCHES "3rdparty")))
|
|
|
|
message(FATAL_ERROR "${tgt}: ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} filename is a duplicate of ${RES}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_sources(${tgt} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
|
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 10:57:55 +01:00
|
|
|
endforeach()
|
2020-09-25 12:55:25 +01:00
|
|
|
endfunction()
|
Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.
Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.
This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.
Addtiionally, this heavily improves our detection of libraries, etc.
2019-04-07 10:57:55 +01:00
|
|
|
|
2023-08-14 18:25:26 +01:00
|
|
|
# Add a file to be compiled.
|
|
|
|
#
|
|
|
|
# add_files([file1 ...] CONDITION condition [condition ...])
|
|
|
|
#
|
|
|
|
# CONDITION is a complete statement that can be evaluated with if().
|
|
|
|
# If it evaluates true, the source files will be added; otherwise not.
|
|
|
|
# For example: ADD_IF SDL_FOUND AND Allegro_FOUND
|
|
|
|
#
|
|
|
|
function(add_files)
|
|
|
|
_add_files_tgt(openttd_lib ${ARGV})
|
|
|
|
endfunction()
|
|
|
|
|
2023-04-10 18:02:31 +01:00
|
|
|
# Add a test file to be compiled.
|
|
|
|
#
|
|
|
|
# add_test_files([file1 ...] CONDITION condition [condition ...])
|
|
|
|
#
|
|
|
|
# CONDITION is a complete statement that can be evaluated with if().
|
|
|
|
# If it evaluates true, the source files will be added; otherwise not.
|
|
|
|
# For example: ADD_IF SDL_FOUND AND Allegro_FOUND
|
|
|
|
#
|
|
|
|
function(add_test_files)
|
2023-08-14 18:25:26 +01:00
|
|
|
_add_files_tgt(openttd_test ${ARGV})
|
2023-04-10 18:02:31 +01:00
|
|
|
endfunction()
|