mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Make codestyle for CMake files consistent for 'control' statements
parent
df5362a008
commit
348c231e12
|
@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
if(NOT BINARY_NAME)
|
if(NOT BINARY_NAME)
|
||||||
set(BINARY_NAME openttd)
|
set(BINARY_NAME openttd)
|
||||||
endif (NOT BINARY_NAME)
|
endif()
|
||||||
|
|
||||||
project(${BINARY_NAME})
|
project(${BINARY_NAME})
|
||||||
|
|
||||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
||||||
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the bin directory")
|
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the bin directory")
|
||||||
endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
endif()
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
||||||
|
@ -17,7 +17,7 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
||||||
# but set our own default data dir
|
# but set our own default data dir
|
||||||
if(NOT CMAKE_INSTALL_DATADIR)
|
if(NOT CMAKE_INSTALL_DATADIR)
|
||||||
set(CMAKE_INSTALL_DATADIR "share/games")
|
set(CMAKE_INSTALL_DATADIR "share/games")
|
||||||
endif (NOT CMAKE_INSTALL_DATADIR)
|
endif()
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
include(Options)
|
include(Options)
|
||||||
|
@ -43,24 +43,24 @@ if (NOT WIN32)
|
||||||
find_package(SDL2)
|
find_package(SDL2)
|
||||||
if(NOT SDL2_FOUND)
|
if(NOT SDL2_FOUND)
|
||||||
find_package(SDL)
|
find_package(SDL)
|
||||||
endif( NOT SDL2_FOUND)
|
endif()
|
||||||
find_package(Fluidsynth)
|
find_package(Fluidsynth)
|
||||||
find_package(Freetype)
|
find_package(Freetype)
|
||||||
find_package(Fontconfig)
|
find_package(Fontconfig)
|
||||||
find_package(ICU OPTIONAL_COMPONENTS i18n lx)
|
find_package(ICU OPTIONAL_COMPONENTS i18n lx)
|
||||||
find_package(XDG_basedir)
|
find_package(XDG_basedir)
|
||||||
else (NOT APPLE)
|
else()
|
||||||
find_package(Iconv)
|
find_package(Iconv)
|
||||||
|
|
||||||
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
|
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
|
||||||
find_library(AUDIOUNIT_LIBRARY AudioUnit)
|
find_library(AUDIOUNIT_LIBRARY AudioUnit)
|
||||||
find_library(COCOA_LIBRARY Cocoa)
|
find_library(COCOA_LIBRARY Cocoa)
|
||||||
endif (NOT APPLE)
|
endif()
|
||||||
endif (NOT WIN32)
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
find_package(Editbin REQUIRED)
|
find_package(Editbin REQUIRED)
|
||||||
endif (MSVC)
|
endif()
|
||||||
|
|
||||||
find_package(SSE)
|
find_package(SSE)
|
||||||
find_package(Xaudio2)
|
find_package(Xaudio2)
|
||||||
|
@ -73,34 +73,34 @@ if (POLICY CMP0069)
|
||||||
cmake_policy(SET CMP0069 NEW)
|
cmake_policy(SET CMP0069 NEW)
|
||||||
include(CheckIPOSupported)
|
include(CheckIPOSupported)
|
||||||
check_ipo_supported(RESULT IPO_FOUND)
|
check_ipo_supported(RESULT IPO_FOUND)
|
||||||
endif (POLICY CMP0069)
|
endif()
|
||||||
|
|
||||||
show_options()
|
show_options()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
|
if(UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
|
||||||
if(NOT SDL_FOUND AND NOT SDL2_FOUND)
|
if(NOT SDL_FOUND AND NOT SDL2_FOUND)
|
||||||
message(FATAL_ERROR "SDL or SDL2 is required for this platform")
|
message(FATAL_ERROR "SDL or SDL2 is required for this platform")
|
||||||
endif (NOT SDL_FOUND AND NOT SDL2_FOUND)
|
endif()
|
||||||
endif (UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
|
endif()
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
if(NOT AUDIOTOOLBOX_LIBRARY)
|
if(NOT AUDIOTOOLBOX_LIBRARY)
|
||||||
message(FATAL_ERROR "AudioToolbox is required for this platform")
|
message(FATAL_ERROR "AudioToolbox is required for this platform")
|
||||||
endif (NOT AUDIOTOOLBOX_LIBRARY)
|
endif()
|
||||||
if(NOT AUDIOUNIT_LIBRARY)
|
if(NOT AUDIOUNIT_LIBRARY)
|
||||||
message(FATAL_ERROR "AudioUnit is required for this platform")
|
message(FATAL_ERROR "AudioUnit is required for this platform")
|
||||||
endif (NOT AUDIOUNIT_LIBRARY)
|
endif()
|
||||||
if(NOT COCOA_LIBRARY)
|
if(NOT COCOA_LIBRARY)
|
||||||
message(FATAL_ERROR "Cocoa is required for this platform")
|
message(FATAL_ERROR "Cocoa is required for this platform")
|
||||||
endif (NOT COCOA_LIBRARY)
|
endif()
|
||||||
endif (APPLE)
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# C++17 for MSVC
|
# C++17 for MSVC
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
else (MSVC)
|
else()
|
||||||
# C++11 for all other targets
|
# C++11 for all other targets
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
endif (MSVC)
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||||
set(CMAKE_CXX_EXTENSIONS NO)
|
set(CMAKE_CXX_EXTENSIONS NO)
|
||||||
|
@ -110,7 +110,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
|
||||||
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/rev.cpp")
|
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/rev.cpp")
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/ottdres.rc")
|
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/ottdres.rc")
|
||||||
endif (WIN32)
|
endif()
|
||||||
|
|
||||||
# Generate a target to determine version, which is execute every 'make' run
|
# Generate a target to determine version, which is execute every 'make' run
|
||||||
add_custom_target(find_version
|
add_custom_target(find_version
|
||||||
|
@ -159,13 +159,13 @@ if (IPO_FOUND)
|
||||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE True)
|
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE True)
|
||||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL True)
|
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL True)
|
||||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True)
|
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True)
|
||||||
endif (IPO_FOUND)
|
endif()
|
||||||
set_target_properties(openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
|
set_target_properties(openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
|
||||||
process_compile_flags()
|
process_compile_flags()
|
||||||
|
|
||||||
if(APPLE OR UNIX)
|
if(APPLE OR UNIX)
|
||||||
add_definitions(-DUNIX)
|
add_definitions(-DUNIX)
|
||||||
endif (APPLE OR UNIX)
|
endif()
|
||||||
|
|
||||||
include(LinkPackage)
|
include(LinkPackage)
|
||||||
link_package(PNG TARGET PNG::PNG ENCOURAGED)
|
link_package(PNG TARGET PNG::PNG ENCOURAGED)
|
||||||
|
@ -183,7 +183,7 @@ if (NOT OPTION_DEDICATED)
|
||||||
link_package(Fontconfig TARGET Fontconfig::Fontconfig)
|
link_package(Fontconfig TARGET Fontconfig::Fontconfig)
|
||||||
link_package(ICU_lx)
|
link_package(ICU_lx)
|
||||||
link_package(ICU_i18n)
|
link_package(ICU_i18n)
|
||||||
endif (NOT OPTION_DEDICATED)
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
link_package(Iconv TARGET Iconv::Iconv)
|
link_package(Iconv TARGET Iconv::Iconv)
|
||||||
|
@ -198,27 +198,27 @@ if (APPLE)
|
||||||
-DWITH_COCOA
|
-DWITH_COCOA
|
||||||
-DENABLE_COCOA_QUARTZ
|
-DENABLE_COCOA_QUARTZ
|
||||||
)
|
)
|
||||||
endif (APPLE)
|
endif()
|
||||||
|
|
||||||
if(NOT PERSONAL_DIR STREQUAL "(not set)")
|
if(NOT PERSONAL_DIR STREQUAL "(not set)")
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DWITH_PERSONAL_DIR
|
-DWITH_PERSONAL_DIR
|
||||||
-DPERSONAL_DIR="${PERSONAL_DIR}"
|
-DPERSONAL_DIR="${PERSONAL_DIR}"
|
||||||
)
|
)
|
||||||
endif (NOT PERSONAL_DIR STREQUAL "(not set)")
|
endif()
|
||||||
|
|
||||||
if(NOT SHARED_DIR STREQUAL "(not set)")
|
if(NOT SHARED_DIR STREQUAL "(not set)")
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DWITH_SHARED_DIR
|
-DWITH_SHARED_DIR
|
||||||
-DSHARED_DIR="${SHARED_DIR}"
|
-DSHARED_DIR="${SHARED_DIR}"
|
||||||
)
|
)
|
||||||
endif (NOT SHARED_DIR STREQUAL "(not set)")
|
endif()
|
||||||
|
|
||||||
if(NOT GLOBAL_DIR STREQUAL "(not set)")
|
if(NOT GLOBAL_DIR STREQUAL "(not set)")
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DGLOBAL_DATA_DIR="${GLOBAL_DIR}"
|
-DGLOBAL_DATA_DIR="${GLOBAL_DIR}"
|
||||||
)
|
)
|
||||||
endif (NOT GLOBAL_DIR STREQUAL "(not set)")
|
endif()
|
||||||
|
|
||||||
link_package(SSE)
|
link_package(SSE)
|
||||||
|
|
||||||
|
@ -236,11 +236,11 @@ if (WIN32)
|
||||||
winmm
|
winmm
|
||||||
imm32
|
imm32
|
||||||
)
|
)
|
||||||
endif (WIN32)
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
add_definitions(-D_SQ64)
|
add_definitions(-D_SQ64)
|
||||||
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
endif()
|
||||||
|
|
||||||
include(CreateRegression)
|
include(CreateRegression)
|
||||||
create_regression()
|
create_regression()
|
||||||
|
|
|
@ -9,7 +9,7 @@ macro(_parse_arguments_with_multi_hack ORIGINAL_COMMAND_LINE)
|
||||||
|
|
||||||
foreach(MULTI IN LISTS MULTIS)
|
foreach(MULTI IN LISTS MULTIS)
|
||||||
string(REPLACE "${MULTI}" "${MULTI};:::" COMMAND_LINE "${COMMAND_LINE}")
|
string(REPLACE "${MULTI}" "${MULTI};:::" COMMAND_LINE "${COMMAND_LINE}")
|
||||||
endforeach(MULTI)
|
endforeach()
|
||||||
|
|
||||||
cmake_parse_arguments(PARAM "${OPTIONS}" "${SINGLES}" "${MULTIS}" ${COMMAND_LINE})
|
cmake_parse_arguments(PARAM "${OPTIONS}" "${SINGLES}" "${MULTIS}" ${COMMAND_LINE})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
@ -21,14 +21,14 @@ macro(_reassemble_command_line)
|
||||||
foreach(OPTION IN LISTS OPTIONS)
|
foreach(OPTION IN LISTS OPTIONS)
|
||||||
if(PARAM_${OPTION})
|
if(PARAM_${OPTION})
|
||||||
list(APPEND NEW_COMMAND_LINE "${OPTION}")
|
list(APPEND NEW_COMMAND_LINE "${OPTION}")
|
||||||
endif (PARAM_${OPTION})
|
endif()
|
||||||
endforeach(OPTION)
|
endforeach()
|
||||||
|
|
||||||
foreach(SINGLE IN LISTS SINGLES)
|
foreach(SINGLE IN LISTS SINGLES)
|
||||||
if(PARAM_${SINGLE})
|
if(PARAM_${SINGLE})
|
||||||
list(APPEND NEW_COMMAND_LINE "${SINGLE}" "${PARAM_${SINGLE}}")
|
list(APPEND NEW_COMMAND_LINE "${SINGLE}" "${PARAM_${SINGLE}}")
|
||||||
endif (PARAM_${SINGLE})
|
endif()
|
||||||
endforeach(SINGLE)
|
endforeach()
|
||||||
|
|
||||||
foreach(MULTI IN LISTS MULTIS)
|
foreach(MULTI IN LISTS MULTIS)
|
||||||
if(PARAM_${MULTI})
|
if(PARAM_${MULTI})
|
||||||
|
@ -36,8 +36,8 @@ macro(_reassemble_command_line)
|
||||||
# restores for example multiple COMMANDs again.
|
# restores for example multiple COMMANDs again.
|
||||||
string(REPLACE ":::" "${MULTI}" PARAM_${MULTI} "${PARAM_${MULTI}}")
|
string(REPLACE ":::" "${MULTI}" PARAM_${MULTI} "${PARAM_${MULTI}}")
|
||||||
list(APPEND NEW_COMMAND_LINE "${PARAM_${MULTI}}")
|
list(APPEND NEW_COMMAND_LINE "${PARAM_${MULTI}}")
|
||||||
endif (PARAM_${MULTI})
|
endif()
|
||||||
endforeach(MULTI)
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Generated files can be older than their dependencies, causing useless
|
# Generated files can be older than their dependencies, causing useless
|
||||||
|
@ -91,12 +91,12 @@ function(add_custom_command_timestamp)
|
||||||
# add_custom_target_timestamp() to know if we should point to the
|
# add_custom_target_timestamp() to know if we should point to the
|
||||||
# '.timestamp' variant or not.
|
# '.timestamp' variant or not.
|
||||||
set_source_files_properties(${OUTPUT} PROPERTIES BYPRODUCT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILENAME}.timestamp)
|
set_source_files_properties(${OUTPUT} PROPERTIES BYPRODUCT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILENAME}.timestamp)
|
||||||
endforeach(OUTPUT)
|
endforeach()
|
||||||
|
|
||||||
# Reassemble and call the wrapped command
|
# Reassemble and call the wrapped command
|
||||||
_reassemble_command_line()
|
_reassemble_command_line()
|
||||||
add_custom_command(${NEW_COMMAND_LINE})
|
add_custom_command(${NEW_COMMAND_LINE})
|
||||||
endfunction(add_custom_command_timestamp)
|
endfunction()
|
||||||
|
|
||||||
# Generated files can be older than their dependencies, causing useless
|
# Generated files can be older than their dependencies, causing useless
|
||||||
# regenerations. This function adds a .timestamp file for each file in DEPENDS
|
# regenerations. This function adds a .timestamp file for each file in DEPENDS
|
||||||
|
@ -133,13 +133,13 @@ function(add_custom_target_timestamp)
|
||||||
if(BYPRODUCT STREQUAL "NOTFOUND")
|
if(BYPRODUCT STREQUAL "NOTFOUND")
|
||||||
# If it is not, just keep it as DEPEND
|
# If it is not, just keep it as DEPEND
|
||||||
list(APPEND PARAM_DEPENDS "${DEPEND}")
|
list(APPEND PARAM_DEPENDS "${DEPEND}")
|
||||||
else (BYPRODUCT STREQUAL "NOTFOUND")
|
else()
|
||||||
# If it is, the BYPRODUCT property points to the timestamp we want to depend on
|
# If it is, the BYPRODUCT property points to the timestamp we want to depend on
|
||||||
list(APPEND PARAM_DEPENDS "${BYPRODUCT}")
|
list(APPEND PARAM_DEPENDS "${BYPRODUCT}")
|
||||||
endif (BYPRODUCT STREQUAL "NOTFOUND")
|
endif()
|
||||||
endforeach(DEPEND)
|
endforeach()
|
||||||
|
|
||||||
# Reassemble and call the wrapped command
|
# Reassemble and call the wrapped command
|
||||||
_reassemble_command_line()
|
_reassemble_command_line()
|
||||||
add_custom_target(${NEW_COMMAND_LINE})
|
add_custom_target(${NEW_COMMAND_LINE})
|
||||||
endfunction(add_custom_target_timestamp)
|
endfunction()
|
||||||
|
|
|
@ -26,11 +26,11 @@ macro(compile_flags)
|
||||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
# Enable multi-threaded compilation.
|
# Enable multi-threaded compilation.
|
||||||
add_compile_options(/MP)
|
add_compile_options(/MP)
|
||||||
endif(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
endif()
|
||||||
|
|
||||||
# Add DPI manifest to project; other WIN32 targets get this via ottdres.rc
|
# Add DPI manifest to project; other WIN32 targets get this via ottdres.rc
|
||||||
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest")
|
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest")
|
||||||
endif (MSVC)
|
endif()
|
||||||
|
|
||||||
# Add some -D flags for Debug builds. We cannot use add_definitions(), because
|
# Add some -D flags for Debug builds. We cannot use add_definitions(), because
|
||||||
# it does not appear to support the $<> tags.
|
# it does not appear to support the $<> tags.
|
||||||
|
@ -42,7 +42,7 @@ macro(compile_flags)
|
||||||
add_link_options(
|
add_link_options(
|
||||||
"$<$<NOT:$<CONFIG:Debug>>:-fstack-protector>" # Prevent undefined references when _FORTIFY_SOURCE > 0
|
"$<$<NOT:$<CONFIG:Debug>>:-fstack-protector>" # Prevent undefined references when _FORTIFY_SOURCE > 0
|
||||||
)
|
)
|
||||||
endif (MINGW)
|
endif()
|
||||||
|
|
||||||
# Prepare a generator that checks if we are not a debug, and don't have asserts
|
# Prepare a generator that checks if we are not a debug, and don't have asserts
|
||||||
# on. We need this later on to set some compile options for stable releases.
|
# on. We need this later on to set some compile options for stable releases.
|
||||||
|
@ -87,12 +87,12 @@ macro(compile_flags)
|
||||||
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-parameter>"
|
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-parameter>"
|
||||||
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-variable>"
|
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-variable>"
|
||||||
)
|
)
|
||||||
else (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
else()
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
"$<${IS_STABLE_RELEASE}:-Wno-unused-variable>"
|
"$<${IS_STABLE_RELEASE}:-Wno-unused-variable>"
|
||||||
"$<${IS_STABLE_RELEASE}:-Wno-unused-parameter>"
|
"$<${IS_STABLE_RELEASE}:-Wno-unused-parameter>"
|
||||||
)
|
)
|
||||||
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
endif()
|
||||||
|
|
||||||
# Ninja processes the output so the output from the compiler
|
# Ninja processes the output so the output from the compiler
|
||||||
# isn't directly to a terminal; hence, the default is
|
# isn't directly to a terminal; hence, the default is
|
||||||
|
@ -104,8 +104,8 @@ macro(compile_flags)
|
||||||
add_compile_options (-fdiagnostics-color=always)
|
add_compile_options (-fdiagnostics-color=always)
|
||||||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||||
add_compile_options (-fcolor-diagnostics)
|
add_compile_options (-fcolor-diagnostics)
|
||||||
endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
endif()
|
||||||
endif (OPTION_FORCE_COLORED_OUTPUT)
|
endif()
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
@ -126,7 +126,7 @@ macro(compile_flags)
|
||||||
# well with our custom pool item allocator
|
# well with our custom pool item allocator
|
||||||
"$<$<BOOL:${LIFETIME_DSE_FOUND}>:-flifetime-dse=1>"
|
"$<$<BOOL:${LIFETIME_DSE_FOUND}>:-flifetime-dse=1>"
|
||||||
)
|
)
|
||||||
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
endif()
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
-Wall
|
-Wall
|
||||||
|
@ -146,5 +146,5 @@ macro(compile_flags)
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
# rdynamic is used to get useful stack traces from crash reports.
|
# rdynamic is used to get useful stack traces from crash reports.
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
|
||||||
endif (NOT WIN32)
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
|
@ -26,7 +26,7 @@ function(create_grf_command)
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND GRF_PNG_BINARY_FILES ${GRF_PNG_BINARY_FILE})
|
list(APPEND GRF_PNG_BINARY_FILES ${GRF_PNG_BINARY_FILE})
|
||||||
endforeach(GRF_PNG_SOURCE_FILE)
|
endforeach()
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${GRF_BINARY_FILE}
|
add_custom_command(OUTPUT ${GRF_BINARY_FILE}
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
|
|
@ -15,7 +15,7 @@ macro(create_regression)
|
||||||
|
|
||||||
if("${REGRESSION_SOURCE_FILE_NAME}" STREQUAL "regression.cfg")
|
if("${REGRESSION_SOURCE_FILE_NAME}" STREQUAL "regression.cfg")
|
||||||
continue()
|
continue()
|
||||||
endif ("${REGRESSION_SOURCE_FILE_NAME}" STREQUAL "regression.cfg")
|
endif()
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${REGRESSION_BINARY_FILE}
|
add_custom_command(OUTPUT ${REGRESSION_BINARY_FILE}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
@ -26,7 +26,7 @@ macro(create_regression)
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND REGRESSION_BINARY_FILES ${REGRESSION_BINARY_FILE})
|
list(APPEND REGRESSION_BINARY_FILES ${REGRESSION_BINARY_FILE})
|
||||||
endforeach(REGRESSION_SOURCE_FILE)
|
endforeach()
|
||||||
|
|
||||||
# Copy the regression configuration in a special folder, so all autogenerated
|
# Copy the regression configuration in a special folder, so all autogenerated
|
||||||
# folders end up in the same place after running regression.
|
# folders end up in the same place after running regression.
|
||||||
|
@ -55,7 +55,7 @@ macro(create_regression)
|
||||||
|
|
||||||
if("${REGRESSION_TEST_NAME}" STREQUAL "regression.cfg")
|
if("${REGRESSION_TEST_NAME}" STREQUAL "regression.cfg")
|
||||||
continue()
|
continue()
|
||||||
endif ("${REGRESSION_TEST_NAME}" STREQUAL "regression.cfg")
|
endif()
|
||||||
|
|
||||||
add_custom_target(regression_${REGRESSION_TEST_NAME}
|
add_custom_target(regression_${REGRESSION_TEST_NAME}
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
@ -78,7 +78,7 @@ macro(create_regression)
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
list(APPEND REGRESSION_TARGETS regression_${REGRESSION_TEST_NAME})
|
list(APPEND REGRESSION_TARGETS regression_${REGRESSION_TEST_NAME})
|
||||||
endforeach(REGRESSION_TEST)
|
endforeach()
|
||||||
|
|
||||||
# Create a new target which runs the regression
|
# Create a new target which runs the regression
|
||||||
add_custom_target(regression
|
add_custom_target(regression
|
||||||
|
|
|
@ -8,7 +8,7 @@ function(add_endian_definition)
|
||||||
|
|
||||||
if(IS_BIG_ENDIAN)
|
if(IS_BIG_ENDIAN)
|
||||||
add_definitions(-DTTD_ENDIAN=TTD_BIG_ENDIAN)
|
add_definitions(-DTTD_ENDIAN=TTD_BIG_ENDIAN)
|
||||||
else (IS_BIG_ENDIAN)
|
else()
|
||||||
add_definitions(-DTTD_ENDIAN=TTD_LITTLE_ENDIAN)
|
add_definitions(-DTTD_ENDIAN=TTD_LITTLE_ENDIAN)
|
||||||
endif (IS_BIG_ENDIAN)
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -4,12 +4,12 @@ if (NOT EDITBIN_DIRECTORY)
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
get_filename_component(MSVC_COMPILE_DIRECTORY ${CMAKE_CXX_COMPILER} DIRECTORY)
|
get_filename_component(MSVC_COMPILE_DIRECTORY ${CMAKE_CXX_COMPILER} DIRECTORY)
|
||||||
set(EDITBIN_DIRECTORY ${MSVC_COMPILE_DIRECTORY})
|
set(EDITBIN_DIRECTORY ${MSVC_COMPILE_DIRECTORY})
|
||||||
else (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
else()
|
||||||
# For clang-cl build
|
# For clang-cl build
|
||||||
# find editbin.exe from environmental variable VCToolsInstallDir
|
# find editbin.exe from environmental variable VCToolsInstallDir
|
||||||
set(EDITBIN_DIRECTORY "$ENV{VCToolsInstallDir}/bin/Hostx64/x64")
|
set(EDITBIN_DIRECTORY "$ENV{VCToolsInstallDir}/bin/Hostx64/x64")
|
||||||
endif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
endif()
|
||||||
endif (NOT EDITBIN_DIRECTORY)
|
endif()
|
||||||
|
|
||||||
message(CHECK_START "Finding editbin.exe")
|
message(CHECK_START "Finding editbin.exe")
|
||||||
find_program(
|
find_program(
|
||||||
|
@ -19,9 +19,9 @@ find_program(
|
||||||
|
|
||||||
if(EDITBIN_EXECUTABLE)
|
if(EDITBIN_EXECUTABLE)
|
||||||
message(CHECK_PASS "found")
|
message(CHECK_PASS "found")
|
||||||
else (EDITBIN_EXECUTABLE)
|
else()
|
||||||
message(CHECK_FAIL "not found , please manually specify EDITBIN_DIRECTORY")
|
message(CHECK_FAIL "not found , please manually specify EDITBIN_DIRECTORY")
|
||||||
endif (EDITBIN_EXECUTABLE)
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(Editbin
|
find_package_handle_standard_args(Editbin
|
||||||
|
|
|
@ -6,7 +6,7 @@ set(CMAKE_REQUIRED_FLAGS "")
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||||
set(CMAKE_REQUIRED_FLAGS "-msse4.1")
|
set(CMAKE_REQUIRED_FLAGS "-msse4.1")
|
||||||
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
endif()
|
||||||
|
|
||||||
check_cxx_source_compiles("
|
check_cxx_source_compiles("
|
||||||
#include <xmmintrin.h>
|
#include <xmmintrin.h>
|
||||||
|
|
|
@ -6,12 +6,12 @@ if (OPTION_INSTALL_FHS)
|
||||||
set(DATA_DESTINATION_DIR "${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}")
|
set(DATA_DESTINATION_DIR "${CMAKE_INSTALL_DATADIR}/${BINARY_NAME}")
|
||||||
set(DOCS_DESTINATION_DIR "${CMAKE_INSTALL_DOCDIR}")
|
set(DOCS_DESTINATION_DIR "${CMAKE_INSTALL_DOCDIR}")
|
||||||
set(MAN_DESTINATION_DIR "${CMAKE_INSTALL_MANDIR}")
|
set(MAN_DESTINATION_DIR "${CMAKE_INSTALL_MANDIR}")
|
||||||
else (OPTION_INSTALL_FHS)
|
else()
|
||||||
set(BINARY_DESTINATION_DIR ".")
|
set(BINARY_DESTINATION_DIR ".")
|
||||||
set(DATA_DESTINATION_DIR ".")
|
set(DATA_DESTINATION_DIR ".")
|
||||||
set(DOCS_DESTINATION_DIR ".")
|
set(DOCS_DESTINATION_DIR ".")
|
||||||
set(MAN_DESTINATION_DIR ".")
|
set(MAN_DESTINATION_DIR ".")
|
||||||
endif (OPTION_INSTALL_FHS)
|
endif()
|
||||||
|
|
||||||
install(TARGETS openttd
|
install(TARGETS openttd
|
||||||
RUNTIME
|
RUNTIME
|
||||||
|
@ -52,26 +52,26 @@ if (OPTION_INSTALL_FHS)
|
||||||
${MAN_BINARY_FILE}.gz
|
${MAN_BINARY_FILE}.gz
|
||||||
DESTINATION ${MAN_DESTINATION_DIR}/man6
|
DESTINATION ${MAN_DESTINATION_DIR}/man6
|
||||||
COMPONENT manual)
|
COMPONENT manual)
|
||||||
endif (OPTION_INSTALL_FHS)
|
endif()
|
||||||
|
|
||||||
# TODO -- Media files
|
# TODO -- Media files
|
||||||
# TODO -- Menu files
|
# TODO -- Menu files
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||||
set(ARCHITECTURE "amd64")
|
set(ARCHITECTURE "amd64")
|
||||||
else (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
else()
|
||||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCHITECTURE)
|
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCHITECTURE)
|
||||||
endif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
endif()
|
||||||
|
|
||||||
# Windows is a bit more annoying to detect; using the size of void pointer
|
# Windows is a bit more annoying to detect; using the size of void pointer
|
||||||
# seems to be the most robust.
|
# seems to be the most robust.
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
set(ARCHITECTURE "win64")
|
set(ARCHITECTURE "win64")
|
||||||
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
else()
|
||||||
set(ARCHITECTURE "win32")
|
set(ARCHITECTURE "win32")
|
||||||
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
endif()
|
||||||
endif (WIN32)
|
endif()
|
||||||
|
|
||||||
set(CPACK_SYSTEM_NAME "${ARCHITECTURE}")
|
set(CPACK_SYSTEM_NAME "${ARCHITECTURE}")
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ elseif (WIN32)
|
||||||
if(OPTION_USE_NSIS)
|
if(OPTION_USE_NSIS)
|
||||||
list(APPEND CPACK_GENERATOR "NSIS")
|
list(APPEND CPACK_GENERATOR "NSIS")
|
||||||
include(PackageNSIS)
|
include(PackageNSIS)
|
||||||
endif (OPTION_USE_NSIS)
|
endif()
|
||||||
|
|
||||||
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-windows-${CPACK_SYSTEM_NAME}")
|
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-windows-${CPACK_SYSTEM_NAME}")
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
|
@ -110,9 +110,9 @@ elseif (UNIX)
|
||||||
if(OPTION_INSTALL_FHS)
|
if(OPTION_INSTALL_FHS)
|
||||||
set(CPACK_GENERATOR "DEB")
|
set(CPACK_GENERATOR "DEB")
|
||||||
include(PackageDeb)
|
include(PackageDeb)
|
||||||
else (OPTION_INSTALL_FHS)
|
else()
|
||||||
set(CPACK_GENERATOR "TXZ")
|
set(CPACK_GENERATOR "TXZ")
|
||||||
endif (OPTION_INSTALL_FHS)
|
endif()
|
||||||
|
|
||||||
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-linux-${CPACK_SYSTEM_NAME}")
|
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-linux-${CPACK_SYSTEM_NAME}")
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -24,17 +24,17 @@ function(set_directory_options)
|
||||||
if(NOT PERSONAL_DIR)
|
if(NOT PERSONAL_DIR)
|
||||||
set(PERSONAL_DIR "${DEFAULT_PERSONAL_DIR}" CACHE STRING "Personal directory")
|
set(PERSONAL_DIR "${DEFAULT_PERSONAL_DIR}" CACHE STRING "Personal directory")
|
||||||
message(STATUS "Detecting Personal Data directory - ${PERSONAL_DIR}")
|
message(STATUS "Detecting Personal Data directory - ${PERSONAL_DIR}")
|
||||||
endif (NOT PERSONAL_DIR)
|
endif()
|
||||||
|
|
||||||
if(NOT SHARED_DIR)
|
if(NOT SHARED_DIR)
|
||||||
set(SHARED_DIR "${DEFAULT_SHARED_DIR}" CACHE STRING "Shared directory")
|
set(SHARED_DIR "${DEFAULT_SHARED_DIR}" CACHE STRING "Shared directory")
|
||||||
message(STATUS "Detecting Shared Data directory - ${SHARED_DIR}")
|
message(STATUS "Detecting Shared Data directory - ${SHARED_DIR}")
|
||||||
endif (NOT SHARED_DIR)
|
endif()
|
||||||
|
|
||||||
if(NOT GLOBAL_DIR)
|
if(NOT GLOBAL_DIR)
|
||||||
set(GLOBAL_DIR "${DEFAULT_GLOBAL_DIR}" CACHE STRING "Global directory")
|
set(GLOBAL_DIR "${DEFAULT_GLOBAL_DIR}" CACHE STRING "Global directory")
|
||||||
message(STATUS "Detecting Global Data directory - ${GLOBAL_DIR}")
|
message(STATUS "Detecting Global Data directory - ${GLOBAL_DIR}")
|
||||||
endif (NOT GLOBAL_DIR)
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Set some generic options that influence what is being build.
|
# Set some generic options that influence what is being build.
|
||||||
|
@ -44,9 +44,9 @@ endfunction()
|
||||||
function(set_options)
|
function(set_options)
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
set(DEFAULT_OPTION_INSTALL_FHS ON)
|
set(DEFAULT_OPTION_INSTALL_FHS ON)
|
||||||
else (UNIX AND NOT APPLE)
|
else()
|
||||||
set(DEFAULT_OPTION_INSTALL_FHS OFF)
|
set(DEFAULT_OPTION_INSTALL_FHS OFF)
|
||||||
endif (UNIX AND NOT APPLE)
|
endif()
|
||||||
|
|
||||||
option(OPTION_FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF)
|
option(OPTION_FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF)
|
||||||
|
|
||||||
|
@ -76,15 +76,15 @@ endfunction()
|
||||||
function(add_definitions_based_on_options)
|
function(add_definitions_based_on_options)
|
||||||
if(OPTION_DEDICATED)
|
if(OPTION_DEDICATED)
|
||||||
add_definitions(-DDEDICATED)
|
add_definitions(-DDEDICATED)
|
||||||
endif (OPTION_DEDICATED)
|
endif()
|
||||||
|
|
||||||
if(NOT OPTION_USE_THREADS)
|
if(NOT OPTION_USE_THREADS)
|
||||||
add_definitions(-DNO_THREADS)
|
add_definitions(-DNO_THREADS)
|
||||||
endif (NOT OPTION_USE_THREADS)
|
endif()
|
||||||
|
|
||||||
if(OPTION_USE_ASSERTS)
|
if(OPTION_USE_ASSERTS)
|
||||||
add_definitions(-DWITH_ASSERT)
|
add_definitions(-DWITH_ASSERT)
|
||||||
else (OPTION_USE_ASSERTS)
|
else()
|
||||||
add_definitions(-DNDEBUG)
|
add_definitions(-DNDEBUG)
|
||||||
endif (OPTION_USE_ASSERTS)
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -13,13 +13,13 @@ function(add_files)
|
||||||
if(PARAM_CONDITION)
|
if(PARAM_CONDITION)
|
||||||
if(NOT (${PARAM_CONDITION}))
|
if(NOT (${PARAM_CONDITION}))
|
||||||
return()
|
return()
|
||||||
endif (NOT (${PARAM_CONDITION}))
|
endif()
|
||||||
endif (PARAM_CONDITION)
|
endif()
|
||||||
|
|
||||||
foreach(FILE IN LISTS PARAM_FILES)
|
foreach(FILE IN LISTS PARAM_FILES)
|
||||||
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
|
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction(add_files)
|
endfunction()
|
||||||
|
|
||||||
# This function works around an 'issue' with CMake, where
|
# This function works around an 'issue' with CMake, where
|
||||||
# set_source_files_properties() only works in the scope of the file. We want
|
# set_source_files_properties() only works in the scope of the file. We want
|
||||||
|
@ -42,7 +42,7 @@ function(set_compile_flags)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY source_properties "${SOURCE_PROPERTIES}")
|
set_property(GLOBAL PROPERTY source_properties "${SOURCE_PROPERTIES}")
|
||||||
endfunction(set_compile_flags)
|
endfunction()
|
||||||
|
|
||||||
# Call this macro in the same CMakeLists.txt and after add_executable().
|
# Call this macro in the same CMakeLists.txt and after add_executable().
|
||||||
# This makes sure all the COMPILE_FLAGS of set_compile_flags() are set
|
# This makes sure all the COMPILE_FLAGS of set_compile_flags() are set
|
||||||
|
@ -60,4 +60,4 @@ function(process_compile_flags)
|
||||||
|
|
||||||
set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS ${PROPERTIES})
|
set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS ${PROPERTIES})
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction(process_compile_flags)
|
endfunction()
|
||||||
|
|
|
@ -14,11 +14,11 @@ while(ARGC LESS CMAKE_ARGC)
|
||||||
|
|
||||||
if(ARG_READ)
|
if(ARG_READ)
|
||||||
list(APPEND LANG_SOURCE_FILES "${ARG}")
|
list(APPEND LANG_SOURCE_FILES "${ARG}")
|
||||||
endif (ARG_READ)
|
endif()
|
||||||
|
|
||||||
if(ARG STREQUAL "--")
|
if(ARG STREQUAL "--")
|
||||||
set(ARG_READ YES)
|
set(ARG_READ YES)
|
||||||
endif (ARG STREQUAL "--")
|
endif()
|
||||||
|
|
||||||
math(EXPR ARGC "${ARGC} + 1")
|
math(EXPR ARGC "${ARGC} + 1")
|
||||||
endwhile()
|
endwhile()
|
||||||
|
@ -35,7 +35,7 @@ foreach(LANGFILE IN LISTS LANG_SOURCE_FILES)
|
||||||
string(FIND "${LANGLINES}" "${STR_ID}" HAS_STR_ID)
|
string(FIND "${LANGLINES}" "${STR_ID}" HAS_STR_ID)
|
||||||
if(HAS_STR_ID LESS 0)
|
if(HAS_STR_ID LESS 0)
|
||||||
continue()
|
continue()
|
||||||
endif (HAS_STR_ID LESS 0)
|
endif()
|
||||||
string(REGEX REPLACE "##isocode ([^;]+).*" "\\1" ISOCODE "${LANGLINES}")
|
string(REGEX REPLACE "##isocode ([^;]+).*" "\\1" ISOCODE "${LANGLINES}")
|
||||||
if("${ISOCODE}" STREQUAL "en_GB")
|
if("${ISOCODE}" STREQUAL "en_GB")
|
||||||
string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY} = \\1" LANGLINES "${LANGLINES}")
|
string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY} = \\1" LANGLINES "${LANGLINES}")
|
||||||
|
@ -43,7 +43,7 @@ foreach(LANGFILE IN LISTS LANG_SOURCE_FILES)
|
||||||
string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY}.${ISOCODE} = \\1" LANGLINES "${LANGLINES}")
|
string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY}.${ISOCODE} = \\1" LANGLINES "${LANGLINES}")
|
||||||
endif()
|
endif()
|
||||||
list(APPEND ${PLACE_HOLDER} ${LANGLINES})
|
list(APPEND ${PLACE_HOLDER} ${LANGLINES})
|
||||||
endforeach(LANGFILE)
|
endforeach()
|
||||||
list(SORT ${PLACE_HOLDER})
|
list(SORT ${PLACE_HOLDER})
|
||||||
string(REPLACE ";" "\n" ${PLACE_HOLDER} "${${PLACE_HOLDER}}")
|
string(REPLACE ";" "\n" ${PLACE_HOLDER} "${${PLACE_HOLDER}}")
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,16 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
if(NOT NFORENUM_EXECUTABLE)
|
if(NOT NFORENUM_EXECUTABLE)
|
||||||
message(FATAL_ERROR "Script needs NFORENUM_EXECUTABLE defined")
|
message(FATAL_ERROR "Script needs NFORENUM_EXECUTABLE defined")
|
||||||
endif (NOT NFORENUM_EXECUTABLE)
|
endif()
|
||||||
if(NOT GRFCODEC_EXECUTABLE)
|
if(NOT GRFCODEC_EXECUTABLE)
|
||||||
message(FATAL_ERROR "Script needs GRFCODEC_EXECUTABLE defined")
|
message(FATAL_ERROR "Script needs GRFCODEC_EXECUTABLE defined")
|
||||||
endif (NOT GRFCODEC_EXECUTABLE)
|
endif()
|
||||||
if(NOT GRF_SOURCE_FOLDER)
|
if(NOT GRF_SOURCE_FOLDER)
|
||||||
message(FATAL_ERROR "Script needs GRF_SOURCE_FOLDER defined")
|
message(FATAL_ERROR "Script needs GRF_SOURCE_FOLDER defined")
|
||||||
endif (NOT GRF_SOURCE_FOLDER)
|
endif()
|
||||||
if(NOT GRF_BINARY_FILE)
|
if(NOT GRF_BINARY_FILE)
|
||||||
message(FATAL_ERROR "Script needs GRF_BINARY_FILE defined")
|
message(FATAL_ERROR "Script needs GRF_BINARY_FILE defined")
|
||||||
endif (NOT GRF_BINARY_FILE)
|
endif()
|
||||||
|
|
||||||
get_filename_component(GRF_SOURCE_FOLDER_NAME "${GRF_SOURCE_FOLDER}" NAME)
|
get_filename_component(GRF_SOURCE_FOLDER_NAME "${GRF_SOURCE_FOLDER}" NAME)
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@ foreach(NFO_LINE IN LISTS NFO_LINES)
|
||||||
string(REGEX REPLACE "^#include \"(.*)\"$" "\\1" INCLUDE_FILE ${NFO_LINE})
|
string(REGEX REPLACE "^#include \"(.*)\"$" "\\1" INCLUDE_FILE ${NFO_LINE})
|
||||||
file(READ ${GRF_SOURCE_FOLDER}/${INCLUDE_FILE} INCLUDE_LINES)
|
file(READ ${GRF_SOURCE_FOLDER}/${INCLUDE_FILE} INCLUDE_LINES)
|
||||||
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${INCLUDE_LINES}")
|
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${INCLUDE_LINES}")
|
||||||
else (NFO_LINE MATCHES "^#include")
|
else()
|
||||||
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${NFO_LINE}\n")
|
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${NFO_LINE}\n")
|
||||||
endif (NFO_LINE MATCHES "^#include")
|
endif()
|
||||||
endforeach(NFO_LINE)
|
endforeach()
|
||||||
|
|
||||||
execute_process(COMMAND ${NFORENUM_EXECUTABLE} -s sprites/${GRF_SOURCE_FOLDER_NAME}.nfo)
|
execute_process(COMMAND ${NFORENUM_EXECUTABLE} -s sprites/${GRF_SOURCE_FOLDER_NAME}.nfo)
|
||||||
execute_process(COMMAND ${GRFCODEC_EXECUTABLE} -n -s -e -p1 ${GRF_SOURCE_FOLDER_NAME}.grf)
|
execute_process(COMMAND ${GRFCODEC_EXECUTABLE} -n -s -e -p1 ${GRF_SOURCE_FOLDER_NAME}.grf)
|
||||||
|
|
|
@ -123,7 +123,7 @@ message(STATUS "Version string: ${REV_VERSION}")
|
||||||
if(GENERATE_OTTDREV)
|
if(GENERATE_OTTDREV)
|
||||||
message(STATUS "Generating .ottdrev")
|
message(STATUS "Generating .ottdrev")
|
||||||
file(WRITE ${CMAKE_SOURCE_DIR}/.ottdrev "${REV_VERSION}\t${REV_ISODATE}\t${REV_MODIFIED}\t${REV_HASH}\t${REV_ISTAG}\t${REV_ISSTABLETAG}\t${REV_YEAR}\n")
|
file(WRITE ${CMAKE_SOURCE_DIR}/.ottdrev "${REV_VERSION}\t${REV_ISODATE}\t${REV_MODIFIED}\t${REV_HASH}\t${REV_ISTAG}\t${REV_ISSTABLETAG}\t${REV_YEAR}\n")
|
||||||
else (GENERATE_OTTDREV)
|
else()
|
||||||
message(STATUS "Generating rev.cpp")
|
message(STATUS "Generating rev.cpp")
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/src/rev.cpp.in"
|
configure_file("${CMAKE_SOURCE_DIR}/src/rev.cpp.in"
|
||||||
"${FIND_VERSION_BINARY_DIR}/rev.cpp")
|
"${FIND_VERSION_BINARY_DIR}/rev.cpp")
|
||||||
|
@ -132,9 +132,9 @@ else (GENERATE_OTTDREV)
|
||||||
message(STATUS "Generating ottdres.rc")
|
message(STATUS "Generating ottdres.rc")
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/src/os/windows/ottdres.rc.in"
|
configure_file("${CMAKE_SOURCE_DIR}/src/os/windows/ottdres.rc.in"
|
||||||
"${FIND_VERSION_BINARY_DIR}/ottdres.rc")
|
"${FIND_VERSION_BINARY_DIR}/ottdres.rc")
|
||||||
endif (WIN32)
|
endif()
|
||||||
|
|
||||||
message(STATUS "Generating CPackProperties.cmake")
|
message(STATUS "Generating CPackProperties.cmake")
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/CPackProperties.cmake.in"
|
configure_file("${CMAKE_SOURCE_DIR}/CPackProperties.cmake.in"
|
||||||
"${CPACK_BINARY_DIR}/CPackProperties.cmake" @ONLY)
|
"${CPACK_BINARY_DIR}/CPackProperties.cmake" @ONLY)
|
||||||
endif (GENERATE_OTTDREV)
|
endif()
|
||||||
|
|
|
@ -17,10 +17,10 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
if(NOT GENERATE_SOURCE_FILE)
|
if(NOT GENERATE_SOURCE_FILE)
|
||||||
message(FATAL_ERROR "Script needs GENERATE_SOURCE_FILE defined")
|
message(FATAL_ERROR "Script needs GENERATE_SOURCE_FILE defined")
|
||||||
endif (NOT GENERATE_SOURCE_FILE)
|
endif()
|
||||||
if(NOT GENERATE_BINARY_FILE)
|
if(NOT GENERATE_BINARY_FILE)
|
||||||
message(FATAL_ERROR "Script needs GENERATE_BINARY_FILE defined")
|
message(FATAL_ERROR "Script needs GENERATE_BINARY_FILE defined")
|
||||||
endif (NOT GENERATE_BINARY_FILE)
|
endif()
|
||||||
|
|
||||||
file(STRINGS ${GENERATE_SOURCE_FILE} ENUM_LINES REGEX "@enum")
|
file(STRINGS ${GENERATE_SOURCE_FILE} ENUM_LINES REGEX "@enum")
|
||||||
|
|
||||||
|
@ -62,19 +62,19 @@ foreach(ENUM IN LISTS ENUM_LINES)
|
||||||
set(ACTIVE 1)
|
set(ACTIVE 1)
|
||||||
if(ACTIVE_COMMENT GREATER 0)
|
if(ACTIVE_COMMENT GREATER 0)
|
||||||
string(APPEND ${PLACE_HOLDER} "\n${COMMENT}")
|
string(APPEND ${PLACE_HOLDER} "\n${COMMENT}")
|
||||||
endif (ACTIVE_COMMENT GREATER 0)
|
endif()
|
||||||
unset(ACTIVE_COMMENT)
|
unset(ACTIVE_COMMENT)
|
||||||
unset(COMMENT)
|
unset(COMMENT)
|
||||||
endif ("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{")
|
endif()
|
||||||
|
|
||||||
# Forget doxygen comment, if no enum follows
|
# Forget doxygen comment, if no enum follows
|
||||||
if(ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "")
|
if(ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "")
|
||||||
unset(ACTIVE_COMMENT)
|
unset(ACTIVE_COMMENT)
|
||||||
unset(COMMENT)
|
unset(COMMENT)
|
||||||
endif (ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "")
|
endif()
|
||||||
if(ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/")
|
if(ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/")
|
||||||
set(ACTIVE_COMMENT 2)
|
set(ACTIVE_COMMENT 2)
|
||||||
endif (ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/")
|
endif()
|
||||||
|
|
||||||
if(ACTIVE)
|
if(ACTIVE)
|
||||||
if("${LINE}" MATCHES "^ *[A-Za-z0-9_]* *[,=]")
|
if("${LINE}" MATCHES "^ *[A-Za-z0-9_]* *[,=]")
|
||||||
|
@ -92,28 +92,28 @@ foreach(ENUM IN LISTS ENUM_LINES)
|
||||||
unset(SPACES)
|
unset(SPACES)
|
||||||
foreach(i RANGE ${LEN})
|
foreach(i RANGE ${LEN})
|
||||||
string(APPEND SPACES " ")
|
string(APPEND SPACES " ")
|
||||||
endforeach(i)
|
endforeach()
|
||||||
|
|
||||||
if(CMAKE_MATCH_3)
|
if(CMAKE_MATCH_3)
|
||||||
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${CMAKE_MATCH_1}${CMAKE_MATCH_2}${SPACES} = ::${CMAKE_MATCH_2},${SPACES}${CMAKE_MATCH_3}")
|
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${CMAKE_MATCH_1}${CMAKE_MATCH_2}${SPACES} = ::${CMAKE_MATCH_2},${SPACES}${CMAKE_MATCH_3}")
|
||||||
else (CMAKE_MATCH_3)
|
else()
|
||||||
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${CMAKE_MATCH_1}${CMAKE_MATCH_2}${SPACES} = ::${CMAKE_MATCH_2},")
|
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${CMAKE_MATCH_1}${CMAKE_MATCH_2}${SPACES} = ::${CMAKE_MATCH_2},")
|
||||||
endif (CMAKE_MATCH_3)
|
endif()
|
||||||
elseif("${LINE}" STREQUAL "")
|
elseif("${LINE}" STREQUAL "")
|
||||||
string(APPEND ${PLACE_HOLDER} "\n")
|
string(APPEND ${PLACE_HOLDER} "\n")
|
||||||
else()
|
else()
|
||||||
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${LINE}")
|
string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${LINE}")
|
||||||
endif()
|
endif()
|
||||||
endif (ACTIVE)
|
endif()
|
||||||
|
|
||||||
if("${LINE}" MATCHES "^ *\};")
|
if("${LINE}" MATCHES "^ *\};")
|
||||||
if(ACTIVE)
|
if(ACTIVE)
|
||||||
string(APPEND ${PLACE_HOLDER} "\n")
|
string(APPEND ${PLACE_HOLDER} "\n")
|
||||||
endif (ACTIVE)
|
endif()
|
||||||
unset(ACTIVE)
|
unset(ACTIVE)
|
||||||
endif ("${LINE}" MATCHES "^ *\};")
|
endif()
|
||||||
endforeach(LINE)
|
endforeach()
|
||||||
endforeach(FILE)
|
endforeach()
|
||||||
endforeach(ENUM)
|
endforeach()
|
||||||
|
|
||||||
configure_file(${GENERATE_SOURCE_FILE} ${GENERATE_BINARY_FILE})
|
configure_file(${GENERATE_SOURCE_FILE} ${GENERATE_BINARY_FILE})
|
||||||
|
|
|
@ -6,10 +6,10 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
if(NOT REGRESSION_TEST)
|
if(NOT REGRESSION_TEST)
|
||||||
message(FATAL_ERROR "Script needs REGRESSION_TEST defined (tip: use -DREGRESSION_TEST=..)")
|
message(FATAL_ERROR "Script needs REGRESSION_TEST defined (tip: use -DREGRESSION_TEST=..)")
|
||||||
endif (NOT REGRESSION_TEST)
|
endif()
|
||||||
if(NOT OPENTTD_EXECUTABLE)
|
if(NOT OPENTTD_EXECUTABLE)
|
||||||
message(FATAL_ERROR "Script needs OPENTTD_EXECUTABLE defined (tip: use -DOPENTTD_EXECUTABLE=..)")
|
message(FATAL_ERROR "Script needs OPENTTD_EXECUTABLE defined (tip: use -DOPENTTD_EXECUTABLE=..)")
|
||||||
endif (NOT OPENTTD_EXECUTABLE)
|
endif()
|
||||||
|
|
||||||
if(NOT EXISTS ai/${REGRESSION_TEST}/test.sav)
|
if(NOT EXISTS ai/${REGRESSION_TEST}/test.sav)
|
||||||
message(FATAL_ERROR "Regression test ${REGRESSION_TEST} does not exist (tip: check regression folder for the correct spelling)")
|
message(FATAL_ERROR "Regression test ${REGRESSION_TEST} does not exist (tip: check regression folder for the correct spelling)")
|
||||||
|
@ -23,7 +23,7 @@ if (EDITBIN_EXECUTABLE)
|
||||||
set(OPENTTD_EXECUTABLE "regression/${REGRESSION_TEST}.exe")
|
set(OPENTTD_EXECUTABLE "regression/${REGRESSION_TEST}.exe")
|
||||||
|
|
||||||
execute_process(COMMAND ${EDITBIN_EXECUTABLE} /nologo /subsystem:console ${OPENTTD_EXECUTABLE})
|
execute_process(COMMAND ${EDITBIN_EXECUTABLE} /nologo /subsystem:console ${OPENTTD_EXECUTABLE})
|
||||||
endif (EDITBIN_EXECUTABLE)
|
endif()
|
||||||
|
|
||||||
# Run the regression test
|
# Run the regression test
|
||||||
execute_process(COMMAND ${OPENTTD_EXECUTABLE}
|
execute_process(COMMAND ${OPENTTD_EXECUTABLE}
|
||||||
|
@ -42,11 +42,11 @@ execute_process(COMMAND ${OPENTTD_EXECUTABLE}
|
||||||
|
|
||||||
if(REGRESSION_OUTPUT)
|
if(REGRESSION_OUTPUT)
|
||||||
message(FATAL_ERROR "Unexpected output: ${REGRESSION_OUTPUT}")
|
message(FATAL_ERROR "Unexpected output: ${REGRESSION_OUTPUT}")
|
||||||
endif (REGRESSION_OUTPUT)
|
endif()
|
||||||
|
|
||||||
if(NOT REGRESSION_RESULT)
|
if(NOT REGRESSION_RESULT)
|
||||||
message(FATAL_ERROR "Regression did not output anything; did the compilation fail?")
|
message(FATAL_ERROR "Regression did not output anything; did the compilation fail?")
|
||||||
endif (NOT REGRESSION_RESULT)
|
endif()
|
||||||
|
|
||||||
# For some reason pointer can be printed as '0x(nil)', '0x0000000000000000', or '0x0x0'
|
# For some reason pointer can be printed as '0x(nil)', '0x0000000000000000', or '0x0x0'
|
||||||
string(REPLACE "0x(nil)" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
string(REPLACE "0x(nil)" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||||
|
@ -80,17 +80,17 @@ foreach(RESULT IN LISTS REGRESSION_RESULT)
|
||||||
message("${ARGC}: - ${EXPECTED}")
|
message("${ARGC}: - ${EXPECTED}")
|
||||||
message("${ARGC}: + ${RESULT}'")
|
message("${ARGC}: + ${RESULT}'")
|
||||||
set(ERROR YES)
|
set(ERROR YES)
|
||||||
endif (NOT RESULT STREQUAL EXPECTED)
|
endif()
|
||||||
|
|
||||||
math(EXPR ARGC "${ARGC} + 1")
|
math(EXPR ARGC "${ARGC} + 1")
|
||||||
endforeach(RESULT)
|
endforeach()
|
||||||
|
|
||||||
if(NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC)
|
if(NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC)
|
||||||
math(EXPR MISSING "${REGRESSION_EXPECTED_LENGTH} - ${ARGC}")
|
math(EXPR MISSING "${REGRESSION_EXPECTED_LENGTH} - ${ARGC}")
|
||||||
message("(${MISSING} more lines were expected than found)")
|
message("(${MISSING} more lines were expected than found)")
|
||||||
set(ERROR YES)
|
set(ERROR YES)
|
||||||
endif (NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC)
|
endif()
|
||||||
|
|
||||||
if(ERROR)
|
if(ERROR)
|
||||||
message(FATAL_ERROR "Regression failed")
|
message(FATAL_ERROR "Regression failed")
|
||||||
endif (ERROR)
|
endif()
|
||||||
|
|
|
@ -2,19 +2,19 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
if(NOT SCRIPT_API_SOURCE_FILE)
|
if(NOT SCRIPT_API_SOURCE_FILE)
|
||||||
message(FATAL_ERROR "Script needs SCRIPT_API_SOURCE_FILE defined")
|
message(FATAL_ERROR "Script needs SCRIPT_API_SOURCE_FILE defined")
|
||||||
endif (NOT SCRIPT_API_SOURCE_FILE)
|
endif()
|
||||||
if(NOT SCRIPT_API_BINARY_FILE)
|
if(NOT SCRIPT_API_BINARY_FILE)
|
||||||
message(FATAL_ERROR "Script needs SCRIPT_API_BINARY_FILE defined")
|
message(FATAL_ERROR "Script needs SCRIPT_API_BINARY_FILE defined")
|
||||||
endif (NOT SCRIPT_API_BINARY_FILE)
|
endif()
|
||||||
if(NOT SCRIPT_API_FILE)
|
if(NOT SCRIPT_API_FILE)
|
||||||
message(FATAL_ERROR "Script needs SCRIPT_API_FILE defined")
|
message(FATAL_ERROR "Script needs SCRIPT_API_FILE defined")
|
||||||
endif (NOT SCRIPT_API_FILE)
|
endif()
|
||||||
if(NOT APIUC)
|
if(NOT APIUC)
|
||||||
message(FATAL_ERROR "Script needs APIUC defined")
|
message(FATAL_ERROR "Script needs APIUC defined")
|
||||||
endif (NOT APIUC)
|
endif()
|
||||||
if(NOT APILC)
|
if(NOT APILC)
|
||||||
message(FATAL_ERROR "Script needs APILC defined")
|
message(FATAL_ERROR "Script needs APILC defined")
|
||||||
endif (NOT APILC)
|
endif()
|
||||||
|
|
||||||
macro(dump_fileheader)
|
macro(dump_fileheader)
|
||||||
get_filename_component(SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE}" NAME)
|
get_filename_component(SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE}" NAME)
|
||||||
|
@ -22,8 +22,8 @@ macro(dump_fileheader)
|
||||||
if(NOT "${APIUC}" STREQUAL "Template")
|
if(NOT "${APIUC}" STREQUAL "Template")
|
||||||
string(REPLACE "script_" "template_" SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE_NAME}")
|
string(REPLACE "script_" "template_" SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE_NAME}")
|
||||||
string(APPEND SQUIRREL_EXPORT "\n#include \"../template/${SCRIPT_API_FILE_NAME}.sq\"")
|
string(APPEND SQUIRREL_EXPORT "\n#include \"../template/${SCRIPT_API_FILE_NAME}.sq\"")
|
||||||
endif (NOT "${APIUC}" STREQUAL "Template")
|
endif()
|
||||||
endmacro(dump_fileheader)
|
endmacro()
|
||||||
|
|
||||||
macro(dump_class_templates NAME)
|
macro(dump_class_templates NAME)
|
||||||
string(REGEX REPLACE "^Script" "" REALNAME ${NAME})
|
string(REGEX REPLACE "^Script" "" REALNAME ${NAME})
|
||||||
|
@ -48,7 +48,7 @@ macro(dump_class_templates NAME)
|
||||||
else()
|
else()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${NAME} *>(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; }")
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${NAME} *>(HSQUIRRELVM vm, ${NAME} *res) { if (res == nullptr) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, \"${REALNAME}\", res, nullptr, DefSQDestructorCallback<${NAME}>, true); return 1; }")
|
||||||
endif()
|
endif()
|
||||||
endmacro(dump_class_templates)
|
endmacro()
|
||||||
|
|
||||||
macro(reset_reader)
|
macro(reset_reader)
|
||||||
unset(ENUMS)
|
unset(ENUMS)
|
||||||
|
@ -63,7 +63,7 @@ macro(reset_reader)
|
||||||
unset(START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
unset(START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
||||||
set(CLS_LEVEL 0)
|
set(CLS_LEVEL 0)
|
||||||
unset(CLS_IN_API)
|
unset(CLS_IN_API)
|
||||||
endmacro(reset_reader)
|
endmacro()
|
||||||
|
|
||||||
reset_reader()
|
reset_reader()
|
||||||
|
|
||||||
|
@ -100,15 +100,15 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
# By default, classes are not selected
|
# By default, classes are not selected
|
||||||
if(NOT CLS_LEVEL)
|
if(NOT CLS_LEVEL)
|
||||||
set(API_SELECTED FALSE)
|
set(API_SELECTED FALSE)
|
||||||
endif (NOT CLS_LEVEL)
|
endif()
|
||||||
|
|
||||||
if("${APIUC}" STREQUAL "Template")
|
if("${APIUC}" STREQUAL "Template")
|
||||||
set(API_SELECTED TRUE)
|
set(API_SELECTED TRUE)
|
||||||
if("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
if("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
||||||
set(API_SELECTED FALSE)
|
set(API_SELECTED FALSE)
|
||||||
endif ("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif("${APIUC}" STREQUAL "Template")
|
endif()
|
||||||
|
|
||||||
if("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
if("${LINE}" STREQUAL "none" OR "${LINE}" STREQUAL "-all")
|
||||||
set(API_SELECTED FALSE)
|
set(API_SELECTED FALSE)
|
||||||
|
@ -118,25 +118,25 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
set(API_SELECTED TRUE)
|
set(API_SELECTED TRUE)
|
||||||
endif()
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^([ ]*)\\* @api (.*)$")
|
endif()
|
||||||
|
|
||||||
# Remove the old squirrel stuff
|
# Remove the old squirrel stuff
|
||||||
if("${LINE}" MATCHES "#ifdef DEFINE_SQUIRREL_CLASS")
|
if("${LINE}" MATCHES "#ifdef DEFINE_SQUIRREL_CLASS")
|
||||||
set(SQUIRREL_STUFF TRUE)
|
set(SQUIRREL_STUFF TRUE)
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "#ifdef DEFINE_SQUIRREL_CLASS")
|
endif()
|
||||||
if("${LINE}" MATCHES "^#endif /\\* DEFINE_SQUIRREL_CLASS \\*/")
|
if("${LINE}" MATCHES "^#endif /\\* DEFINE_SQUIRREL_CLASS \\*/")
|
||||||
unset(SQUIRREL_STUFF)
|
unset(SQUIRREL_STUFF)
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^#endif /\\* DEFINE_SQUIRREL_CLASS \\*/")
|
endif()
|
||||||
if(SQUIRREL_STUFF)
|
if(SQUIRREL_STUFF)
|
||||||
continue()
|
continue()
|
||||||
endif (SQUIRREL_STUFF)
|
endif()
|
||||||
|
|
||||||
# Ignore forward declarations of classes
|
# Ignore forward declarations of classes
|
||||||
if("${LINE}" MATCHES "^( *)class(.*);")
|
if("${LINE}" MATCHES "^( *)class(.*);")
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^( *)class(.*);")
|
endif()
|
||||||
|
|
||||||
# We only want to have public functions exported for now
|
# We only want to have public functions exported for now
|
||||||
if("${LINE}" MATCHES "^( *)class (.*) (: public|: protected|: private|:) ([^ ]*)")
|
if("${LINE}" MATCHES "^( *)class (.*) (: public|: protected|: private|:) ([^ ]*)")
|
||||||
|
@ -144,7 +144,7 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
if(NOT DEFINED API_SELECTED)
|
if(NOT DEFINED API_SELECTED)
|
||||||
message(WARNING "Class '${CMAKE_MATCH_2}' has no @api. It won't be published to any API.")
|
message(WARNING "Class '${CMAKE_MATCH_2}' has no @api. It won't be published to any API.")
|
||||||
set(API_SELECTED FALSE)
|
set(API_SELECTED FALSE)
|
||||||
endif (NOT DEFINED API_SELECTED)
|
endif()
|
||||||
unset(IS_PUBLIC)
|
unset(IS_PUBLIC)
|
||||||
unset(CLS_PARAM_0)
|
unset(CLS_PARAM_0)
|
||||||
set(CLS_PARAM_1 1)
|
set(CLS_PARAM_1 1)
|
||||||
|
@ -156,54 +156,54 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
elseif(CLS_LEVEL EQUAL 1)
|
elseif(CLS_LEVEL EQUAL 1)
|
||||||
if(NOT DEFINED API_SELECTED)
|
if(NOT DEFINED API_SELECTED)
|
||||||
set(API_SELECTED ${CLS_IN_API})
|
set(API_SELECTED ${CLS_IN_API})
|
||||||
endif (NOT API_SELECTED)
|
endif()
|
||||||
|
|
||||||
if(API_SELECTED)
|
if(API_SELECTED)
|
||||||
list(APPEND STRUCTS "${CLS}::${CMAKE_MATCH_2}")
|
list(APPEND STRUCTS "${CLS}::${CMAKE_MATCH_2}")
|
||||||
endif (API_SELECTED)
|
endif()
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
endif()
|
endif()
|
||||||
math(EXPR CLS_LEVEL "${CLS_LEVEL} + 1")
|
math(EXPR CLS_LEVEL "${CLS_LEVEL} + 1")
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^( *)class (.*) (: public|: protected|: private|:) ([^ ]*)")
|
endif()
|
||||||
if("${LINE}" MATCHES "^( *)public")
|
if("${LINE}" MATCHES "^( *)public")
|
||||||
if(CLS_LEVEL EQUAL 1)
|
if(CLS_LEVEL EQUAL 1)
|
||||||
set(IS_PUBLIC TRUE)
|
set(IS_PUBLIC TRUE)
|
||||||
endif (CLS_LEVEL EQUAL 1)
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^( *)public")
|
endif()
|
||||||
if("${LINE}" MATCHES "^( *)protected")
|
if("${LINE}" MATCHES "^( *)protected")
|
||||||
if(CLS_LEVEL EQUAL 1)
|
if(CLS_LEVEL EQUAL 1)
|
||||||
unset(IS_PUBLIC)
|
unset(IS_PUBLIC)
|
||||||
endif (CLS_LEVEL EQUAL 1)
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^( *)protected")
|
endif()
|
||||||
if("${LINE}" MATCHES "^( *)private")
|
if("${LINE}" MATCHES "^( *)private")
|
||||||
if(CLS_LEVEL EQUAL 1)
|
if(CLS_LEVEL EQUAL 1)
|
||||||
unset(IS_PUBLIC)
|
unset(IS_PUBLIC)
|
||||||
endif (CLS_LEVEL EQUAL 1)
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^( *)private")
|
endif()
|
||||||
|
|
||||||
# Ignore the comments
|
# Ignore the comments
|
||||||
if("${LINE}" MATCHES "^#")
|
if("${LINE}" MATCHES "^#")
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^#")
|
endif()
|
||||||
if("${LINE}" MATCHES "/\\*.*\\*/")
|
if("${LINE}" MATCHES "/\\*.*\\*/")
|
||||||
unset(COMMENT)
|
unset(COMMENT)
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "/\\*.*\\*/")
|
endif()
|
||||||
if("${LINE}" MATCHES "/\\*")
|
if("${LINE}" MATCHES "/\\*")
|
||||||
set(COMMENT TRUE)
|
set(COMMENT TRUE)
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "/\\*")
|
endif()
|
||||||
if("${LINE}" MATCHES "\\*/")
|
if("${LINE}" MATCHES "\\*/")
|
||||||
unset(COMMENT)
|
unset(COMMENT)
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "\\*/")
|
endif()
|
||||||
if(COMMENT)
|
if(COMMENT)
|
||||||
continue()
|
continue()
|
||||||
endif (COMMENT)
|
endif()
|
||||||
|
|
||||||
# We need to make specialized conversions for structs
|
# We need to make specialized conversions for structs
|
||||||
if("${LINE}" MATCHES "^( *)struct ([^ ]*)")
|
if("${LINE}" MATCHES "^( *)struct ([^ ]*)")
|
||||||
|
@ -212,20 +212,20 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
# Check if we want to publish this struct
|
# Check if we want to publish this struct
|
||||||
if(NOT DEFINED API_SELECTED)
|
if(NOT DEFINED API_SELECTED)
|
||||||
set(API_SELECTED ${CLS_IN_API})
|
set(API_SELECTED ${CLS_IN_API})
|
||||||
endif (NOT DEFINED API_SELECTED)
|
endif()
|
||||||
if(NOT API_SELECTED)
|
if(NOT API_SELECTED)
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT API_SELECTED)
|
endif()
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
|
|
||||||
if(NOT IS_PUBLIC OR NOT CLS_LEVEL EQUAL 1)
|
if(NOT IS_PUBLIC OR NOT CLS_LEVEL EQUAL 1)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT IS_PUBLIC OR NOT CLS_LEVEL EQUAL 1)
|
endif()
|
||||||
|
|
||||||
list(APPEND STRUCTS "${CLS}::${CMAKE_MATCH_2}")
|
list(APPEND STRUCTS "${CLS}::${CMAKE_MATCH_2}")
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^( *)struct ([^ ]*)")
|
endif()
|
||||||
|
|
||||||
# We need to make specialized conversions for enums
|
# We need to make specialized conversions for enums
|
||||||
if("${LINE}" MATCHES "^( *)enum ([^ ]*)")
|
if("${LINE}" MATCHES "^( *)enum ([^ ]*)")
|
||||||
|
@ -234,21 +234,21 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
# Check if we want to publish this enum
|
# Check if we want to publish this enum
|
||||||
if(NOT DEFINED API_SELECTED)
|
if(NOT DEFINED API_SELECTED)
|
||||||
set(API_SELECTED ${CLS_IN_API})
|
set(API_SELECTED ${CLS_IN_API})
|
||||||
endif (NOT DEFINED API_SELECTED)
|
endif()
|
||||||
if(NOT API_SELECTED)
|
if(NOT API_SELECTED)
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT API_SELECTED)
|
endif()
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
|
|
||||||
if(NOT IS_PUBLIC)
|
if(NOT IS_PUBLIC)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT IS_PUBLIC)
|
endif()
|
||||||
|
|
||||||
set(IN_ENUM TRUE)
|
set(IN_ENUM TRUE)
|
||||||
list(APPEND ENUMS "${CLS}::${CMAKE_MATCH_2}")
|
list(APPEND ENUMS "${CLS}::${CMAKE_MATCH_2}")
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^( *)enum ([^ ]*)")
|
endif()
|
||||||
|
|
||||||
# Maybe the end of the class, if so we can start with the Squirrel export pretty soon
|
# Maybe the end of the class, if so we can start with the Squirrel export pretty soon
|
||||||
if("${LINE}" MATCHES "};")
|
if("${LINE}" MATCHES "};")
|
||||||
|
@ -256,29 +256,29 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
if(CLS_LEVEL)
|
if(CLS_LEVEL)
|
||||||
unset(IN_ENUM)
|
unset(IN_ENUM)
|
||||||
continue()
|
continue()
|
||||||
endif (CLS_LEVEL)
|
endif()
|
||||||
|
|
||||||
if(CLS)
|
if(CLS)
|
||||||
set(START_SQUIRREL_DEFINE_ON_NEXT_LINE TRUE)
|
set(START_SQUIRREL_DEFINE_ON_NEXT_LINE TRUE)
|
||||||
endif (CLS)
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "};")
|
endif()
|
||||||
|
|
||||||
# Empty/white lines. When we may do the Squirrel export, do that export.
|
# Empty/white lines. When we may do the Squirrel export, do that export.
|
||||||
if("${LINE}" MATCHES "^([ ]*)$")
|
if("${LINE}" MATCHES "^([ ]*)$")
|
||||||
if(NOT START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
if(NOT START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT START_SQUIRREL_DEFINE_ON_NEXT_LINE)
|
endif()
|
||||||
|
|
||||||
if(NOT CLS_IN_API)
|
if(NOT CLS_IN_API)
|
||||||
reset_reader()
|
reset_reader()
|
||||||
continue()
|
continue()
|
||||||
endif (NOT CLS_IN_API)
|
endif()
|
||||||
|
|
||||||
if(NOT HAS_FILEHEADER)
|
if(NOT HAS_FILEHEADER)
|
||||||
dump_fileheader()
|
dump_fileheader()
|
||||||
set(HAS_FILEHEADER TRUE)
|
set(HAS_FILEHEADER TRUE)
|
||||||
endif (NOT HAS_FILEHEADER)
|
endif()
|
||||||
|
|
||||||
unset(IS_PUBLIC)
|
unset(IS_PUBLIC)
|
||||||
unset(NAMESPACE_OPENED)
|
unset(NAMESPACE_OPENED)
|
||||||
|
@ -294,32 +294,32 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
if(NOT NAMESPACE_OPENED)
|
if(NOT NAMESPACE_OPENED)
|
||||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
||||||
set(NAMESPACE_OPENED TRUE)
|
set(NAMESPACE_OPENED TRUE)
|
||||||
endif (NOT NAMESPACE_OPENED)
|
endif()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n /* Allow enums to be used as Squirrel parameters */")
|
string(APPEND SQUIRREL_EXPORT "\n /* Allow enums to be used as Squirrel parameters */")
|
||||||
foreach(ENUM IN LISTS ENUMS)
|
foreach(ENUM IN LISTS ENUMS)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${ENUM} GetParam(ForceType<${ENUM}>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (${ENUM})tmp; }")
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline ${ENUM} GetParam(ForceType<${ENUM}>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (${ENUM})tmp; }")
|
||||||
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${ENUM}>(HSQUIRRELVM vm, ${ENUM} res) { sq_pushinteger(vm, (int32)res); return 1; }")
|
string(APPEND SQUIRREL_EXPORT "\n template <> inline int Return<${ENUM}>(HSQUIRRELVM vm, ${ENUM} res) { sq_pushinteger(vm, (int32)res); return 1; }")
|
||||||
endforeach(ENUM)
|
endforeach()
|
||||||
endif (DEFINED ENUMS)
|
endif()
|
||||||
|
|
||||||
# Then check whether we have structs/classes to print
|
# Then check whether we have structs/classes to print
|
||||||
if(DEFINED STRUCTS)
|
if(DEFINED STRUCTS)
|
||||||
if(NOT NAMESPACE_OPENED)
|
if(NOT NAMESPACE_OPENED)
|
||||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
||||||
set(NAMESPACE_OPENED TRUE)
|
set(NAMESPACE_OPENED TRUE)
|
||||||
endif (NOT NAMESPACE_OPENED)
|
endif()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n /* Allow inner classes/structs to be used as Squirrel parameters */")
|
string(APPEND SQUIRREL_EXPORT "\n /* Allow inner classes/structs to be used as Squirrel parameters */")
|
||||||
foreach(STRUCT IN LISTS STRUCTS)
|
foreach(STRUCT IN LISTS STRUCTS)
|
||||||
dump_class_templates(${STRUCT})
|
dump_class_templates(${STRUCT})
|
||||||
endforeach(STRUCT)
|
endforeach()
|
||||||
endif (DEFINED STRUCTS)
|
endif()
|
||||||
|
|
||||||
if(NOT NAMESPACE_OPENED)
|
if(NOT NAMESPACE_OPENED)
|
||||||
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
string(APPEND SQUIRREL_EXPORT "\nnamespace SQConvert {")
|
||||||
set(NAMESPACE_OPENED TRUE)
|
set(NAMESPACE_OPENED TRUE)
|
||||||
else (NOT NAMESPACE_OPENED)
|
else()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
endif (NOT NAMESPACE_OPENED)
|
endif()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n /* Allow ${CLS} to be used as Squirrel parameter */")
|
string(APPEND SQUIRREL_EXPORT "\n /* Allow ${CLS} to be used as Squirrel parameter */")
|
||||||
dump_class_templates(${CLS})
|
dump_class_templates(${CLS})
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
|
|
||||||
reset_reader()
|
reset_reader()
|
||||||
continue()
|
continue()
|
||||||
endif ("${APIUC}" STREQUAL "Template")
|
endif()
|
||||||
|
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
string(APPEND SQUIRREL_EXPORT "\ntemplate <> const char *GetClassName<${CLS}, ST_${APIUC}>() { return \"${API_CLS}\"; }")
|
string(APPEND SQUIRREL_EXPORT "\ntemplate <> const char *GetClassName<${CLS}, ST_${APIUC}>() { return \"${API_CLS}\"; }")
|
||||||
|
@ -339,16 +339,16 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n DefSQClass<${CLS}, ST_${APIUC}> SQ${API_CLS}(\"${API_CLS}\");")
|
string(APPEND SQUIRREL_EXPORT "\n DefSQClass<${CLS}, ST_${APIUC}> SQ${API_CLS}(\"${API_CLS}\");")
|
||||||
if("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
if("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine);")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine);")
|
||||||
else ("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
else()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine, \"${API_SUPER_CLS}\");")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PreRegister(engine, \"${API_SUPER_CLS}\");")
|
||||||
endif ("${SUPER_CLS}" STREQUAL "Text" OR "${SUPER_CLS}" STREQUAL "ScriptObject" OR "${SUPER_CLS}" STREQUAL "AIAbstractiveList::Valuator")
|
endif()
|
||||||
if(NOT "${SUPER_CLS}" STREQUAL "ScriptEvent")
|
if(NOT "${SUPER_CLS}" STREQUAL "ScriptEvent")
|
||||||
if("${CLS_PARAM_2}" STREQUAL "v")
|
if("${CLS_PARAM_2}" STREQUAL "v")
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.AddSQAdvancedConstructor(engine);")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.AddSQAdvancedConstructor(engine);")
|
||||||
else ("${CLS_PARAM_2}" STREQUAL "v")
|
else()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.AddConstructor<void (${CLS}::*)(${CLS_PARAM_0}), ${CLS_PARAM_1}>(engine, \"${CLS_PARAM_2}\");")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.AddConstructor<void (${CLS}::*)(${CLS_PARAM_0}), ${CLS_PARAM_1}>(engine, \"${CLS_PARAM_2}\");")
|
||||||
endif ("${CLS_PARAM_2}" STREQUAL "v")
|
endif()
|
||||||
endif (NOT "${SUPER_CLS}" STREQUAL "ScriptEvent")
|
endif()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
|
|
||||||
# Enum values
|
# Enum values
|
||||||
|
@ -357,20 +357,20 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(LENGTH "${ENUM_VALUE}" LEN)
|
string(LENGTH "${ENUM_VALUE}" LEN)
|
||||||
if(MLEN LESS LEN)
|
if(MLEN LESS LEN)
|
||||||
set(MLEN ${LEN})
|
set(MLEN ${LEN})
|
||||||
endif (MLEN LESS LEN)
|
endif()
|
||||||
endforeach(ENUM_VALUE)
|
endforeach()
|
||||||
foreach(ENUM_VALUE IN LISTS ENUM_VALUES)
|
foreach(ENUM_VALUE IN LISTS ENUM_VALUES)
|
||||||
string(LENGTH "${ENUM_VALUE}" LEN)
|
string(LENGTH "${ENUM_VALUE}" LEN)
|
||||||
math(EXPR LEN "${MLEN} - ${LEN}")
|
math(EXPR LEN "${MLEN} - ${LEN}")
|
||||||
unset(SPACES)
|
unset(SPACES)
|
||||||
foreach(i RANGE ${LEN})
|
foreach(i RANGE ${LEN})
|
||||||
string(APPEND SPACES " ")
|
string(APPEND SPACES " ")
|
||||||
endforeach(i)
|
endforeach()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQConst(engine, ${CLS}::${ENUM_VALUE},${SPACES}\"${ENUM_VALUE}\");")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQConst(engine, ${CLS}::${ENUM_VALUE},${SPACES}\"${ENUM_VALUE}\");")
|
||||||
endforeach(ENUM_VALUE)
|
endforeach()
|
||||||
if(MLEN)
|
if(MLEN)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
endif (MLEN)
|
endif()
|
||||||
|
|
||||||
# Const values
|
# Const values
|
||||||
set(MLEN 0)
|
set(MLEN 0)
|
||||||
|
@ -378,20 +378,20 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(LENGTH "${CONST_VALUE}" LEN)
|
string(LENGTH "${CONST_VALUE}" LEN)
|
||||||
if(MLEN LESS LEN)
|
if(MLEN LESS LEN)
|
||||||
set(MLEN ${LEN})
|
set(MLEN ${LEN})
|
||||||
endif (MLEN LESS LEN)
|
endif()
|
||||||
endforeach(CONST_VALUE)
|
endforeach()
|
||||||
foreach(CONST_VALUE IN LISTS CONST_VALUES)
|
foreach(CONST_VALUE IN LISTS CONST_VALUES)
|
||||||
string(LENGTH "${CONST_VALUE}" LEN)
|
string(LENGTH "${CONST_VALUE}" LEN)
|
||||||
math(EXPR LEN "${MLEN} - ${LEN}")
|
math(EXPR LEN "${MLEN} - ${LEN}")
|
||||||
unset(SPACES)
|
unset(SPACES)
|
||||||
foreach(i RANGE ${LEN})
|
foreach(i RANGE ${LEN})
|
||||||
string(APPEND SPACES " ")
|
string(APPEND SPACES " ")
|
||||||
endforeach(i)
|
endforeach()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQConst(engine, ${CLS}::${CONST_VALUE},${SPACES}\"${CONST_VALUE}\");")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQConst(engine, ${CLS}::${CONST_VALUE},${SPACES}\"${CONST_VALUE}\");")
|
||||||
endforeach(CONST_VALUE)
|
endforeach()
|
||||||
if(MLEN)
|
if(MLEN)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
endif (MLEN)
|
endif()
|
||||||
|
|
||||||
# Mapping of OTTD strings to errors
|
# Mapping of OTTD strings to errors
|
||||||
set(MLEN 0)
|
set(MLEN 0)
|
||||||
|
@ -401,8 +401,8 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(LENGTH "${ENUM_STRING}" LEN)
|
string(LENGTH "${ENUM_STRING}" LEN)
|
||||||
if(MLEN LESS LEN)
|
if(MLEN LESS LEN)
|
||||||
set(MLEN ${LEN})
|
set(MLEN ${LEN})
|
||||||
endif (MLEN LESS LEN)
|
endif()
|
||||||
endforeach(ENUM_STRING_TO_ERROR)
|
endforeach()
|
||||||
foreach(ENUM_STRING_TO_ERROR IN LISTS ENUM_STRING_TO_ERRORS)
|
foreach(ENUM_STRING_TO_ERROR IN LISTS ENUM_STRING_TO_ERRORS)
|
||||||
string(REPLACE ":" ";" ENUM_STRING_TO_ERROR "${ENUM_STRING_TO_ERROR}")
|
string(REPLACE ":" ";" ENUM_STRING_TO_ERROR "${ENUM_STRING_TO_ERROR}")
|
||||||
list(GET ENUM_STRING_TO_ERROR 0 ENUM_STRING)
|
list(GET ENUM_STRING_TO_ERROR 0 ENUM_STRING)
|
||||||
|
@ -412,12 +412,12 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
unset(SPACES)
|
unset(SPACES)
|
||||||
foreach(i RANGE ${LEN})
|
foreach(i RANGE ${LEN})
|
||||||
string(APPEND SPACES " ")
|
string(APPEND SPACES " ")
|
||||||
endforeach(i)
|
endforeach()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n ScriptError::RegisterErrorMap(${ENUM_STRING},${SPACES}${CLS}::${ENUM_ERROR});")
|
string(APPEND SQUIRREL_EXPORT "\n ScriptError::RegisterErrorMap(${ENUM_STRING},${SPACES}${CLS}::${ENUM_ERROR});")
|
||||||
endforeach(ENUM_STRING_TO_ERROR)
|
endforeach()
|
||||||
if(MLEN)
|
if(MLEN)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
endif (MLEN)
|
endif()
|
||||||
|
|
||||||
# Mapping of errors to human 'readable' strings.
|
# Mapping of errors to human 'readable' strings.
|
||||||
set(MLEN 0)
|
set(MLEN 0)
|
||||||
|
@ -425,20 +425,20 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(LENGTH "${ENUM_ERROR_TO_STRING}" LEN)
|
string(LENGTH "${ENUM_ERROR_TO_STRING}" LEN)
|
||||||
if(MLEN LESS LEN)
|
if(MLEN LESS LEN)
|
||||||
set(MLEN ${LEN})
|
set(MLEN ${LEN})
|
||||||
endif (MLEN LESS LEN)
|
endif()
|
||||||
endforeach(ENUM_ERROR_TO_STRING)
|
endforeach()
|
||||||
foreach(ENUM_ERROR_TO_STRING IN LISTS ENUM_ERROR_TO_STRINGS)
|
foreach(ENUM_ERROR_TO_STRING IN LISTS ENUM_ERROR_TO_STRINGS)
|
||||||
string(LENGTH "${ENUM_ERROR_TO_STRING}" LEN)
|
string(LENGTH "${ENUM_ERROR_TO_STRING}" LEN)
|
||||||
math(EXPR LEN "${MLEN} - ${LEN}")
|
math(EXPR LEN "${MLEN} - ${LEN}")
|
||||||
unset(SPACES)
|
unset(SPACES)
|
||||||
foreach(i RANGE ${LEN})
|
foreach(i RANGE ${LEN})
|
||||||
string(APPEND SPACES " ")
|
string(APPEND SPACES " ")
|
||||||
endforeach(i)
|
endforeach()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n ScriptError::RegisterErrorMapString(${CLS}::${ENUM_ERROR_TO_STRING},${SPACES}\"${ENUM_ERROR_TO_STRING}\");")
|
string(APPEND SQUIRREL_EXPORT "\n ScriptError::RegisterErrorMapString(${CLS}::${ENUM_ERROR_TO_STRING},${SPACES}\"${ENUM_ERROR_TO_STRING}\");")
|
||||||
endforeach(ENUM_ERROR_TO_STRING)
|
endforeach()
|
||||||
if(MLEN)
|
if(MLEN)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
endif (MLEN)
|
endif()
|
||||||
|
|
||||||
# Static methods
|
# Static methods
|
||||||
set(MLEN 0)
|
set(MLEN 0)
|
||||||
|
@ -448,8 +448,8 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(LENGTH "${FUNCNAME}" LEN)
|
string(LENGTH "${FUNCNAME}" LEN)
|
||||||
if(MLEN LESS LEN)
|
if(MLEN LESS LEN)
|
||||||
set(MLEN ${LEN})
|
set(MLEN ${LEN})
|
||||||
endif (MLEN LESS LEN)
|
endif()
|
||||||
endforeach(STATIC_METHOD)
|
endforeach()
|
||||||
foreach(STATIC_METHOD IN LISTS STATIC_METHODS)
|
foreach(STATIC_METHOD IN LISTS STATIC_METHODS)
|
||||||
string(REPLACE ":" ";" STATIC_METHOD "${STATIC_METHOD}")
|
string(REPLACE ":" ";" STATIC_METHOD "${STATIC_METHOD}")
|
||||||
list(GET STATIC_METHOD 0 FUNCNAME)
|
list(GET STATIC_METHOD 0 FUNCNAME)
|
||||||
|
@ -460,23 +460,23 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
if("${TYPES}" STREQUAL "v")
|
if("${TYPES}" STREQUAL "v")
|
||||||
if(LEN GREATER 8)
|
if(LEN GREATER 8)
|
||||||
math(EXPR LEN "${LEN} - 8")
|
math(EXPR LEN "${LEN} - 8")
|
||||||
else (LEN GREATER 8)
|
else()
|
||||||
set(LEN 0)
|
set(LEN 0)
|
||||||
endif (LEN GREATER 8)
|
endif()
|
||||||
endif ("${TYPES}" STREQUAL "v")
|
endif()
|
||||||
unset(SPACES)
|
unset(SPACES)
|
||||||
foreach(i RANGE ${LEN})
|
foreach(i RANGE ${LEN})
|
||||||
string(APPEND SPACES " ")
|
string(APPEND SPACES " ")
|
||||||
endforeach(i)
|
endforeach()
|
||||||
if("${TYPES}" STREQUAL "v")
|
if("${TYPES}" STREQUAL "v")
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQAdvancedStaticMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\");")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQAdvancedStaticMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\");")
|
||||||
else ("${TYPES}" STREQUAL "v")
|
else()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQStaticMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\",${SPACES}${ARGC}, \"${TYPES}\");")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQStaticMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\",${SPACES}${ARGC}, \"${TYPES}\");")
|
||||||
endif ("${TYPES}" STREQUAL "v")
|
endif()
|
||||||
endforeach(STATIC_METHOD)
|
endforeach()
|
||||||
if(MLEN)
|
if(MLEN)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
endif (MLEN)
|
endif()
|
||||||
|
|
||||||
# Non-static methods
|
# Non-static methods
|
||||||
set(MLEN 0)
|
set(MLEN 0)
|
||||||
|
@ -486,8 +486,8 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(LENGTH "${FUNCNAME}" LEN)
|
string(LENGTH "${FUNCNAME}" LEN)
|
||||||
if(MLEN LESS LEN)
|
if(MLEN LESS LEN)
|
||||||
set(MLEN ${LEN})
|
set(MLEN ${LEN})
|
||||||
endif (MLEN LESS LEN)
|
endif()
|
||||||
endforeach(METHOD)
|
endforeach()
|
||||||
foreach(METHOD IN LISTS METHODS)
|
foreach(METHOD IN LISTS METHODS)
|
||||||
string(REPLACE ":" ";" METHOD "${METHOD}")
|
string(REPLACE ":" ";" METHOD "${METHOD}")
|
||||||
list(GET METHOD 0 FUNCNAME)
|
list(GET METHOD 0 FUNCNAME)
|
||||||
|
@ -498,23 +498,23 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
if("${TYPES}" STREQUAL "v")
|
if("${TYPES}" STREQUAL "v")
|
||||||
if(LEN GREATER 8)
|
if(LEN GREATER 8)
|
||||||
math(EXPR LEN "${LEN} - 8")
|
math(EXPR LEN "${LEN} - 8")
|
||||||
else (LEN GREATER 8)
|
else()
|
||||||
set(LEN 0)
|
set(LEN 0)
|
||||||
endif (LEN GREATER 8)
|
endif()
|
||||||
endif ("${TYPES}" STREQUAL "v")
|
endif()
|
||||||
unset(SPACES)
|
unset(SPACES)
|
||||||
foreach(i RANGE ${LEN})
|
foreach(i RANGE ${LEN})
|
||||||
string(APPEND SPACES " ")
|
string(APPEND SPACES " ")
|
||||||
endforeach(i)
|
endforeach()
|
||||||
if("${TYPES}" STREQUAL "v")
|
if("${TYPES}" STREQUAL "v")
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQAdvancedMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\");")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQAdvancedMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\");")
|
||||||
else ("${TYPES}" STREQUAL "v")
|
else()
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\",${SPACES}${ARGC}, \"${TYPES}\");")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.DefSQMethod(engine, &${CLS}::${FUNCNAME},${SPACES}\"${FUNCNAME}\",${SPACES}${ARGC}, \"${TYPES}\");")
|
||||||
endif ("${TYPES}" STREQUAL "v")
|
endif()
|
||||||
endforeach(METHOD)
|
endforeach()
|
||||||
if(MLEN)
|
if(MLEN)
|
||||||
string(APPEND SQUIRREL_EXPORT "\n")
|
string(APPEND SQUIRREL_EXPORT "\n")
|
||||||
endif (MLEN)
|
endif()
|
||||||
|
|
||||||
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PostRegister(engine);")
|
string(APPEND SQUIRREL_EXPORT "\n SQ${API_CLS}.PostRegister(engine);")
|
||||||
string(APPEND SQUIRREL_EXPORT "\n}")
|
string(APPEND SQUIRREL_EXPORT "\n}")
|
||||||
|
@ -522,12 +522,12 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
reset_reader()
|
reset_reader()
|
||||||
|
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^([ ]*)$")
|
endif()
|
||||||
|
|
||||||
# Skip non-public functions
|
# Skip non-public functions
|
||||||
if(NOT IS_PUBLIC)
|
if(NOT IS_PUBLIC)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT IS_PUBLIC)
|
endif()
|
||||||
|
|
||||||
# Add enums
|
# Add enums
|
||||||
if(IN_ENUM)
|
if(IN_ENUM)
|
||||||
|
@ -549,37 +549,37 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
|
|
||||||
foreach(MAPPING IN LISTS MAPPINGS)
|
foreach(MAPPING IN LISTS MAPPINGS)
|
||||||
list(APPEND ENUM_STRING_TO_ERRORS "${MAPPING}:${ENUM_VALUE}")
|
list(APPEND ENUM_STRING_TO_ERRORS "${MAPPING}:${ENUM_VALUE}")
|
||||||
endforeach(MAPPING)
|
endforeach()
|
||||||
|
|
||||||
list(APPEND ENUM_ERROR_TO_STRINGS "${ENUM_VALUE}")
|
list(APPEND ENUM_ERROR_TO_STRINGS "${ENUM_VALUE}")
|
||||||
endif ("${LINE}" MATCHES "\\[(.*)\\]")
|
endif()
|
||||||
endif ("${ENUM}" MATCHES ".*::ErrorMessages")
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif (IN_ENUM)
|
endif()
|
||||||
|
|
||||||
# Add a const (non-enum) value
|
# Add a const (non-enum) value
|
||||||
if("${LINE}" MATCHES "^[ ]*static const [^ ]+ ([^ ]+) = -?\\(?[^ ]*\\)?[^ ]+;")
|
if("${LINE}" MATCHES "^[ ]*static const [^ ]+ ([^ ]+) = -?\\(?[^ ]*\\)?[^ ]+;")
|
||||||
list(APPEND CONST_VALUES "${CMAKE_MATCH_1}")
|
list(APPEND CONST_VALUES "${CMAKE_MATCH_1}")
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^[ ]*static const [^ ]+ ([^ ]+) = -?\\(?[^ ]*\\)?[^ ]+;")
|
endif()
|
||||||
|
|
||||||
# Add a method to the list
|
# Add a method to the list
|
||||||
if("${LINE}" MATCHES "^.*\\(.*\\).*$")
|
if("${LINE}" MATCHES "^.*\\(.*\\).*$")
|
||||||
if(NOT CLS_LEVEL EQUAL 1)
|
if(NOT CLS_LEVEL EQUAL 1)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT CLS_LEVEL EQUAL 1)
|
endif()
|
||||||
if("${LINE}" MATCHES "~")
|
if("${LINE}" MATCHES "~")
|
||||||
if(DEFINED API_SELECTED)
|
if(DEFINED API_SELECTED)
|
||||||
message(WARNING "Destructor for '${CLS}' has @api. Tag ignored.")
|
message(WARNING "Destructor for '${CLS}' has @api. Tag ignored.")
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
endif (DEFINED API_SELECTED)
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "~")
|
endif()
|
||||||
|
|
||||||
unset(IS_STATIC)
|
unset(IS_STATIC)
|
||||||
if("${LINE}" MATCHES "static")
|
if("${LINE}" MATCHES "static")
|
||||||
set(IS_STATIC TRUE)
|
set(IS_STATIC TRUE)
|
||||||
endif ("${LINE}" MATCHES "static")
|
endif()
|
||||||
|
|
||||||
string(REGEX REPLACE "(virtual|static|const)[ ]+" "" LINE "${LINE}")
|
string(REGEX REPLACE "(virtual|static|const)[ ]+" "" LINE "${LINE}")
|
||||||
string(REGEX REPLACE "{.*" "" LINE "${LINE}")
|
string(REGEX REPLACE "{.*" "" LINE "${LINE}")
|
||||||
|
@ -597,11 +597,11 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
if(DEFINED API_SELECTED)
|
if(DEFINED API_SELECTED)
|
||||||
message(WARNING "Constructor for '${CLS}' has @api. Tag ignored.")
|
message(WARNING "Constructor for '${CLS}' has @api. Tag ignored.")
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
endif (DEFINED API_SELECTED)
|
endif()
|
||||||
set(CLS_PARAM_0 "${PARAM_S}")
|
set(CLS_PARAM_0 "${PARAM_S}")
|
||||||
if(NOT PARAM_S)
|
if(NOT PARAM_S)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT PARAM_S)
|
endif()
|
||||||
elseif(NOT FUNCNAME)
|
elseif(NOT FUNCNAME)
|
||||||
continue()
|
continue()
|
||||||
endif()
|
endif()
|
||||||
|
@ -609,9 +609,9 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
string(REPLACE "," ";" PARAMS "${PARAM_S}")
|
string(REPLACE "," ";" PARAMS "${PARAM_S}")
|
||||||
if(IS_STATIC)
|
if(IS_STATIC)
|
||||||
set(TYPES ".")
|
set(TYPES ".")
|
||||||
else (IS_STATIC)
|
else()
|
||||||
set(TYPES "x")
|
set(TYPES "x")
|
||||||
endif (IS_STATIC)
|
endif()
|
||||||
|
|
||||||
set(LEN 1)
|
set(LEN 1)
|
||||||
foreach(PARAM IN LISTS PARAMS)
|
foreach(PARAM IN LISTS PARAMS)
|
||||||
|
@ -639,16 +639,16 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
else()
|
else()
|
||||||
string(APPEND TYPES "i")
|
string(APPEND TYPES "i")
|
||||||
endif()
|
endif()
|
||||||
endforeach(PARAM)
|
endforeach()
|
||||||
|
|
||||||
# Check if we want to publish this function
|
# Check if we want to publish this function
|
||||||
if(NOT DEFINED API_SELECTED)
|
if(NOT DEFINED API_SELECTED)
|
||||||
set(API_SELECTED ${CLS_IN_API})
|
set(API_SELECTED ${CLS_IN_API})
|
||||||
endif (NOT DEFINED API_SELECTED)
|
endif()
|
||||||
if(NOT API_SELECTED)
|
if(NOT API_SELECTED)
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
continue()
|
continue()
|
||||||
endif (NOT API_SELECTED)
|
endif()
|
||||||
unset(API_SELECTED)
|
unset(API_SELECTED)
|
||||||
|
|
||||||
if("${FUNCTYPE}" STREQUAL "${CLS}" AND NOT FUNCNAME)
|
if("${FUNCTYPE}" STREQUAL "${CLS}" AND NOT FUNCNAME)
|
||||||
|
@ -661,7 +661,7 @@ foreach(LINE IN LISTS SOURCE_LINES)
|
||||||
list(APPEND METHODS "${FUNCNAME}:${LEN}:${TYPES}")
|
list(APPEND METHODS "${FUNCNAME}:${LEN}:${TYPES}")
|
||||||
endif()
|
endif()
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "^.*\\(.*\\).*$")
|
endif()
|
||||||
endforeach(LINE)
|
endforeach()
|
||||||
|
|
||||||
configure_file(${SCRIPT_API_SOURCE_FILE} ${SCRIPT_API_BINARY_FILE})
|
configure_file(${SCRIPT_API_SOURCE_FILE} ${SCRIPT_API_BINARY_FILE})
|
||||||
|
|
|
@ -2,16 +2,16 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
if(NOT INCLUDES_SOURCE_FILE)
|
if(NOT INCLUDES_SOURCE_FILE)
|
||||||
message(FATAL_ERROR "Script needs INCLUDES_SOURCE_FILE defined")
|
message(FATAL_ERROR "Script needs INCLUDES_SOURCE_FILE defined")
|
||||||
endif (NOT INCLUDES_SOURCE_FILE)
|
endif()
|
||||||
if(NOT INCLUDES_BINARY_FILE)
|
if(NOT INCLUDES_BINARY_FILE)
|
||||||
message(FATAL_ERROR "Script needs INCLUDES_BINARY_FILE defined")
|
message(FATAL_ERROR "Script needs INCLUDES_BINARY_FILE defined")
|
||||||
endif (NOT INCLUDES_BINARY_FILE)
|
endif()
|
||||||
if(NOT APILC)
|
if(NOT APILC)
|
||||||
message(FATAL_ERROR "Script needs APILC defined")
|
message(FATAL_ERROR "Script needs APILC defined")
|
||||||
endif (NOT APILC)
|
endif()
|
||||||
if(NOT APIUC)
|
if(NOT APIUC)
|
||||||
message(FATAL_ERROR "Script needs APIUC defined")
|
message(FATAL_ERROR "Script needs APIUC defined")
|
||||||
endif (NOT APIUC)
|
endif()
|
||||||
|
|
||||||
set(ARGC 1)
|
set(ARGC 1)
|
||||||
set(ARG_READ NO)
|
set(ARG_READ NO)
|
||||||
|
@ -23,11 +23,11 @@ while(ARGC LESS CMAKE_ARGC)
|
||||||
|
|
||||||
if(ARG_READ)
|
if(ARG_READ)
|
||||||
list(APPEND SCRIPT_API_BINARY_FILES "${ARG}")
|
list(APPEND SCRIPT_API_BINARY_FILES "${ARG}")
|
||||||
endif (ARG_READ)
|
endif()
|
||||||
|
|
||||||
if(ARG STREQUAL "--")
|
if(ARG STREQUAL "--")
|
||||||
set(ARG_READ YES)
|
set(ARG_READ YES)
|
||||||
endif (ARG STREQUAL "--")
|
endif()
|
||||||
|
|
||||||
math(EXPR ARGC "${ARGC} + 1")
|
math(EXPR ARGC "${ARGC} + 1")
|
||||||
endwhile()
|
endwhile()
|
||||||
|
@ -40,13 +40,13 @@ foreach(FILE IN LISTS SCRIPT_API_BINARY_FILES)
|
||||||
foreach(LINE IN LISTS LINES)
|
foreach(LINE IN LISTS LINES)
|
||||||
if("${LINE}" MATCHES "SQ${APIUC}(List|Controller)_Register")
|
if("${LINE}" MATCHES "SQ${APIUC}(List|Controller)_Register")
|
||||||
continue()
|
continue()
|
||||||
endif ("${LINE}" MATCHES "SQ${APIUC}(List|Controller)_Register")
|
endif()
|
||||||
string(REGEX REPLACE "^.*void " " " LINE "${LINE}")
|
string(REGEX REPLACE "^.*void " " " LINE "${LINE}")
|
||||||
string(REGEX REPLACE "Squirrel \\*" "" LINE "${LINE}")
|
string(REGEX REPLACE "Squirrel \\*" "" LINE "${LINE}")
|
||||||
list(APPEND SQUIRREL_REGISTER "${LINE}")
|
list(APPEND SQUIRREL_REGISTER "${LINE}")
|
||||||
endforeach(LINE)
|
endforeach()
|
||||||
endif (LINES)
|
endif()
|
||||||
endforeach(FILE)
|
endforeach()
|
||||||
|
|
||||||
list(SORT SQUIRREL_INCLUDES)
|
list(SORT SQUIRREL_INCLUDES)
|
||||||
string(REPLACE ";" "\n" SQUIRREL_INCLUDES "${SQUIRREL_INCLUDES}")
|
string(REPLACE ";" "\n" SQUIRREL_INCLUDES "${SQUIRREL_INCLUDES}")
|
||||||
|
|
|
@ -26,7 +26,7 @@ if (GRFCODEC_FOUND)
|
||||||
|
|
||||||
list(APPEND BASESET_BINARY_FILES openttd.grf)
|
list(APPEND BASESET_BINARY_FILES openttd.grf)
|
||||||
list(APPEND BASESET_BINARY_FILES orig_extra.grf)
|
list(APPEND BASESET_BINARY_FILES orig_extra.grf)
|
||||||
endif (GRFCODEC_FOUND)
|
endif()
|
||||||
|
|
||||||
set(BASESET_EXTRAGRF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/orig_extra.grf)
|
set(BASESET_EXTRAGRF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/orig_extra.grf)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ foreach(BASESET_SOURCE_FILE IN LISTS BASESET_SOURCE_FILES)
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND BASESET_BINARY_FILES ${BASESET_BINARY_FILE})
|
list(APPEND BASESET_BINARY_FILES ${BASESET_BINARY_FILE})
|
||||||
endforeach(BASESET_SOURCE_FILE)
|
endforeach()
|
||||||
|
|
||||||
# Walk over all the other baseset files, and generate a command to copy them
|
# Walk over all the other baseset files, and generate a command to copy them
|
||||||
foreach(BASESET_OTHER_SOURCE_FILE IN LISTS BASESET_OTHER_SOURCE_FILES)
|
foreach(BASESET_OTHER_SOURCE_FILE IN LISTS BASESET_OTHER_SOURCE_FILES)
|
||||||
|
@ -70,7 +70,7 @@ foreach(BASESET_OTHER_SOURCE_FILE IN LISTS BASESET_OTHER_SOURCE_FILES)
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND BASESET_BINARY_FILES ${BASESET_OTHER_BINARY_FILE})
|
list(APPEND BASESET_BINARY_FILES ${BASESET_OTHER_BINARY_FILE})
|
||||||
endforeach(BASESET_OTHER_SOURCE_FILE)
|
endforeach()
|
||||||
|
|
||||||
# Create a new target which generates all baseset metadata files
|
# Create a new target which generates all baseset metadata files
|
||||||
add_custom_target_timestamp(baseset_files
|
add_custom_target_timestamp(baseset_files
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
if(GRFCODEC_FOUND)
|
if(GRFCODEC_FOUND)
|
||||||
include(CreateGrfCommand)
|
include(CreateGrfCommand)
|
||||||
create_grf_command()
|
create_grf_command()
|
||||||
endif (GRFCODEC_FOUND)
|
endif()
|
||||||
|
|
|
@ -11,4 +11,4 @@ if (GRFCODEC_FOUND)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../openttd/canals.png
|
${CMAKE_CURRENT_SOURCE_DIR}/../openttd/canals.png
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../openttd/chars.png
|
${CMAKE_CURRENT_SOURCE_DIR}/../openttd/chars.png
|
||||||
)
|
)
|
||||||
endif (GRFCODEC_FOUND)
|
endif()
|
||||||
|
|
|
@ -28,7 +28,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clan
|
||||||
set_compile_flags(
|
set_compile_flags(
|
||||||
viewport_sprite_sorter_sse4.cpp
|
viewport_sprite_sorter_sse4.cpp
|
||||||
COMPILE_FLAGS -msse4.1)
|
COMPILE_FLAGS -msse4.1)
|
||||||
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
endif()
|
||||||
|
|
||||||
add_files(
|
add_files(
|
||||||
aircraft.h
|
aircraft.h
|
||||||
|
|
|
@ -44,7 +44,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clan
|
||||||
32bpp_anim_sse4.cpp
|
32bpp_anim_sse4.cpp
|
||||||
32bpp_sse4.cpp
|
32bpp_sse4.cpp
|
||||||
COMPILE_FLAGS -msse4.1)
|
COMPILE_FLAGS -msse4.1)
|
||||||
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
endif()
|
||||||
|
|
||||||
add_files(
|
add_files(
|
||||||
base.hpp
|
base.hpp
|
||||||
|
|
|
@ -78,7 +78,7 @@ foreach(LANG_SOURCE_FILE IN LISTS LANG_SOURCE_FILES)
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND LANG_BINARY_FILES ${LANG_BINARY_FILE})
|
list(APPEND LANG_BINARY_FILES ${LANG_BINARY_FILE})
|
||||||
endforeach(LANG_SOURCE_FILE)
|
endforeach()
|
||||||
|
|
||||||
# Create a new target which compiles all language files
|
# Create a new target which compiles all language files
|
||||||
add_custom_target(language_files
|
add_custom_target(language_files
|
||||||
|
|
|
@ -42,7 +42,7 @@ if (NOT OPTION_DEDICATED)
|
||||||
os2_m.h
|
os2_m.h
|
||||||
CONDITION OPTION_OS2
|
CONDITION OPTION_OS2
|
||||||
)
|
)
|
||||||
endif (NOT OPTION_DEDICATED)
|
endif()
|
||||||
|
|
||||||
add_files(
|
add_files(
|
||||||
midi.h
|
midi.h
|
||||||
|
|
|
@ -8,7 +8,7 @@ foreach(ENUM IN LISTS ENUM_LINES)
|
||||||
string(REGEX REPLACE ".* ([^ @]+)@.*" "\\1" FILE_PATTERN "${ENUM}")
|
string(REGEX REPLACE ".* ([^ @]+)@.*" "\\1" FILE_PATTERN "${ENUM}")
|
||||||
file(GLOB FILENAMES "${FILE_PATTERN}")
|
file(GLOB FILENAMES "${FILE_PATTERN}")
|
||||||
list(APPEND DEPENDENCIES ${FILENAMES})
|
list(APPEND DEPENDENCIES ${FILENAMES})
|
||||||
endforeach(ENUM)
|
endforeach()
|
||||||
list(REMOVE_DUPLICATES DEPENDENCIES)
|
list(REMOVE_DUPLICATES DEPENDENCIES)
|
||||||
|
|
||||||
# Add a command to generate script_window.hpp
|
# Add a command to generate script_window.hpp
|
||||||
|
@ -42,7 +42,7 @@ foreach(API "ai;AI" "game;GS" "template;Template")
|
||||||
foreach(SCRIPT_API_FILE IN LISTS SCRIPT_API_FILES)
|
foreach(SCRIPT_API_FILE IN LISTS SCRIPT_API_FILES)
|
||||||
if("${SCRIPT_API_FILE}" MATCHES ".*script_controller.*")
|
if("${SCRIPT_API_FILE}" MATCHES ".*script_controller.*")
|
||||||
continue()
|
continue()
|
||||||
endif ("${SCRIPT_API_FILE}" MATCHES ".*script_controller.*")
|
endif()
|
||||||
get_filename_component(SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE}" NAME)
|
get_filename_component(SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE}" NAME)
|
||||||
string(REPLACE "script_" "${APILC}_" SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE_NAME}")
|
string(REPLACE "script_" "${APILC}_" SCRIPT_API_FILE_NAME "${SCRIPT_API_FILE_NAME}")
|
||||||
set(SCRIPT_API_BINARY_FILE "${CMAKE_BINARY_DIR}/generated/script/api/${APILC}/${SCRIPT_API_FILE_NAME}.sq")
|
set(SCRIPT_API_BINARY_FILE "${CMAKE_BINARY_DIR}/generated/script/api/${APILC}/${SCRIPT_API_FILE_NAME}.sq")
|
||||||
|
@ -62,7 +62,7 @@ foreach(API "ai;AI" "game;GS" "template;Template")
|
||||||
COMMENT "Generating ${APILC}/${SCRIPT_API_FILE_NAME}.sq"
|
COMMENT "Generating ${APILC}/${SCRIPT_API_FILE_NAME}.sq"
|
||||||
)
|
)
|
||||||
list(APPEND SCRIPT_${APIUC}_BINARY_FILES ${SCRIPT_API_BINARY_FILE})
|
list(APPEND SCRIPT_${APIUC}_BINARY_FILES ${SCRIPT_API_BINARY_FILE})
|
||||||
endforeach(SCRIPT_API_FILE)
|
endforeach()
|
||||||
|
|
||||||
add_custom_target_timestamp(script_${APILC}
|
add_custom_target_timestamp(script_${APILC}
|
||||||
DEPENDS
|
DEPENDS
|
||||||
|
@ -100,11 +100,11 @@ foreach(API "ai;AI" "game;GS" "template;Template")
|
||||||
add_dependencies(script_api
|
add_dependencies(script_api
|
||||||
script_${APILC}_includes
|
script_${APILC}_includes
|
||||||
)
|
)
|
||||||
else (NOT "${APILC}" STREQUAL "template")
|
else()
|
||||||
add_dependencies(script_api
|
add_dependencies(script_api
|
||||||
script_${APILC}
|
script_${APILC}
|
||||||
)
|
)
|
||||||
endif (NOT "${APILC}" STREQUAL "template")
|
endif()
|
||||||
|
|
||||||
target_include_directories(script_api
|
target_include_directories(script_api
|
||||||
INTERFACE
|
INTERFACE
|
||||||
|
@ -112,7 +112,7 @@ foreach(API "ai;AI" "game;GS" "template;Template")
|
||||||
${CMAKE_BINARY_DIR}/generated/script/api/${APILC}
|
${CMAKE_BINARY_DIR}/generated/script/api/${APILC}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${APILC}
|
${CMAKE_CURRENT_SOURCE_DIR}/${APILC}
|
||||||
)
|
)
|
||||||
endforeach(API)
|
endforeach()
|
||||||
|
|
||||||
add_library(openttd::script_api ALIAS script_api)
|
add_library(openttd::script_api ALIAS script_api)
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ if (NOT OPTION_DEDICATED)
|
||||||
xaudio2_s.h
|
xaudio2_s.h
|
||||||
CONDITION WIN32 AND XAUDIO2_FOUND
|
CONDITION WIN32 AND XAUDIO2_FOUND
|
||||||
)
|
)
|
||||||
endif (NOT OPTION_DEDICATED)
|
endif()
|
||||||
|
|
||||||
add_files(
|
add_files(
|
||||||
sound_driver.hpp
|
sound_driver.hpp
|
||||||
|
|
|
@ -24,7 +24,7 @@ if (NOT OPTION_DEDICATED)
|
||||||
win32_v.h
|
win32_v.h
|
||||||
CONDITION WIN32
|
CONDITION WIN32
|
||||||
)
|
)
|
||||||
endif (NOT OPTION_DEDICATED)
|
endif()
|
||||||
|
|
||||||
add_files(
|
add_files(
|
||||||
dedicated_v.cpp
|
dedicated_v.cpp
|
||||||
|
|
Loading…
Reference in New Issue