CMake: Use openttd_lib split build from upstream
Add option to disable for cross-compiling
This commit is contained in:
@@ -254,6 +254,12 @@ if(OPTION_PACKAGE_DEPENDENCIES)
|
|||||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(OPTION_NO_SPLIT_LIB)
|
||||||
|
set(OPENTTD_LIB openttd)
|
||||||
|
else()
|
||||||
|
set(OPENTTD_LIB openttd_lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(SourceList)
|
include(SourceList)
|
||||||
|
|
||||||
@@ -264,11 +270,16 @@ include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/squirrel/include)
|
|||||||
|
|
||||||
include(MSVCFilters)
|
include(MSVCFilters)
|
||||||
|
|
||||||
add_executable(openttd WIN32 ${GENERATED_SOURCE_FILES})
|
if(OPTION_NO_SPLIT_LIB)
|
||||||
set_target_properties(openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}")
|
add_executable(openttd WIN32 ${GENERATED_SOURCE_FILES})
|
||||||
|
else()
|
||||||
|
add_library(openttd_lib OBJECT ${GENERATED_SOURCE_FILES})
|
||||||
|
add_executable(openttd WIN32)
|
||||||
|
add_executable(openttd_test)
|
||||||
|
set_target_properties(openttd_test PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(openttd_test)
|
set_target_properties(openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}")
|
||||||
set_target_properties(openttd_test PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
|
||||||
# All other files are added via target_sources()
|
# All other files are added via target_sources()
|
||||||
|
|
||||||
set(host_tools_list strgen settingsgen)
|
set(host_tools_list strgen settingsgen)
|
||||||
@@ -310,6 +321,7 @@ if(MSVC)
|
|||||||
# If target -static is used, switch our project to static (/MT) too.
|
# If target -static is used, switch our project to static (/MT) too.
|
||||||
# If the target ends on -static-md, it will remain dynamic (/MD).
|
# If the target ends on -static-md, it will remain dynamic (/MD).
|
||||||
if(VCPKG_TARGET_TRIPLET MATCHES "-static" AND NOT VCPKG_TARGET_TRIPLET MATCHES "-md")
|
if(VCPKG_TARGET_TRIPLET MATCHES "-static" AND NOT VCPKG_TARGET_TRIPLET MATCHES "-md")
|
||||||
|
set_property(TARGET openttd_lib PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
set_property(TARGET openttd PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
set_property(TARGET openttd PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
set_property(TARGET openttd_test PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
set_property(TARGET openttd_test PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
endif()
|
endif()
|
||||||
@@ -330,18 +342,25 @@ endif()
|
|||||||
add_dependencies(openttd
|
add_dependencies(openttd
|
||||||
find_version)
|
find_version)
|
||||||
|
|
||||||
target_link_libraries(openttd
|
if(NOT OPTION_NO_SPLIT_LIB)
|
||||||
|
target_link_libraries(openttd openttd_lib)
|
||||||
|
|
||||||
|
target_link_libraries(openttd_test PRIVATE openttd_lib)
|
||||||
|
include(Catch)
|
||||||
|
catch_discover_tests(openttd_test)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(${OPENTTD_LIB}
|
||||||
openttd::languages
|
openttd::languages
|
||||||
openttd::settings
|
openttd::settings
|
||||||
openttd::media
|
|
||||||
openttd::basesets
|
|
||||||
openttd::script_api
|
openttd::script_api
|
||||||
openttd::binfiles
|
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
)
|
)
|
||||||
target_link_libraries(openttd_test)
|
|
||||||
include(Catch)
|
target_link_libraries(openttd
|
||||||
catch_discover_tests(openttd_test)
|
openttd::media
|
||||||
|
openttd::basesets
|
||||||
|
)
|
||||||
|
|
||||||
if(HAIKU)
|
if(HAIKU)
|
||||||
target_link_libraries(openttd "be" "network" "midi")
|
target_link_libraries(openttd "be" "network" "midi")
|
||||||
@@ -395,7 +414,7 @@ include(CheckAtomic)
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
link_package(Iconv TARGET Iconv::Iconv)
|
link_package(Iconv TARGET Iconv::Iconv)
|
||||||
|
|
||||||
target_link_libraries(openttd
|
target_link_libraries(${OPENTTD_LIB}
|
||||||
${AUDIOTOOLBOX_LIBRARY}
|
${AUDIOTOOLBOX_LIBRARY}
|
||||||
${AUDIOUNIT_LIBRARY}
|
${AUDIOUNIT_LIBRARY}
|
||||||
${COCOA_LIBRARY}
|
${COCOA_LIBRARY}
|
||||||
@@ -492,7 +511,7 @@ if(WIN32)
|
|||||||
-DPSAPI_VERSION=1
|
-DPSAPI_VERSION=1
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(openttd
|
target_link_libraries(${OPENTTD_LIB}
|
||||||
ws2_32
|
ws2_32
|
||||||
winmm
|
winmm
|
||||||
imm32
|
imm32
|
||||||
|
|||||||
@@ -83,5 +83,5 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB)
|
if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB)
|
||||||
target_link_libraries(openttd atomic)
|
target_link_libraries(${OPENTTD_LIB} atomic)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ function(link_package NAME)
|
|||||||
# which (later) cmake considers to be an error. Work around this with by stripping the incoming string.
|
# which (later) cmake considers to be an error. Work around this with by stripping the incoming string.
|
||||||
if(LP_TARGET AND TARGET ${LP_TARGET})
|
if(LP_TARGET AND TARGET ${LP_TARGET})
|
||||||
string(STRIP "${LP_TARGET}" LP_TARGET)
|
string(STRIP "${LP_TARGET}" LP_TARGET)
|
||||||
target_link_libraries(openttd ${LP_TARGET})
|
target_link_libraries(${OPENTTD_LIB} ${LP_TARGET})
|
||||||
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${LP_TARGET}")
|
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${LP_TARGET}")
|
||||||
else()
|
else()
|
||||||
string(STRIP "${${NAME}_LIBRARY}" ${NAME}_LIBRARY)
|
string(STRIP "${${NAME}_LIBRARY}" ${NAME}_LIBRARY)
|
||||||
string(STRIP "${${NAME}_LIBRARIES}" ${NAME}_LIBRARIES)
|
string(STRIP "${${NAME}_LIBRARIES}" ${NAME}_LIBRARIES)
|
||||||
include_directories(${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR})
|
include_directories(${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR})
|
||||||
target_link_libraries(openttd ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY})
|
target_link_libraries(${OPENTTD_LIB} ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY})
|
||||||
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR} -- ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY}")
|
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR} -- ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY}")
|
||||||
endif()
|
endif()
|
||||||
elseif(LP_ENCOURAGED)
|
elseif(LP_ENCOURAGED)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ endfunction()
|
|||||||
# For example: ADD_IF SDL_FOUND AND Allegro_FOUND
|
# For example: ADD_IF SDL_FOUND AND Allegro_FOUND
|
||||||
#
|
#
|
||||||
function(add_files)
|
function(add_files)
|
||||||
_add_files_tgt(openttd ${ARGV})
|
_add_files_tgt(${OPENTTD_LIB} ${ARGV})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Add a test file to be compiled.
|
# Add a test file to be compiled.
|
||||||
@@ -44,7 +44,9 @@ endfunction()
|
|||||||
# For example: ADD_IF SDL_FOUND AND Allegro_FOUND
|
# For example: ADD_IF SDL_FOUND AND Allegro_FOUND
|
||||||
#
|
#
|
||||||
function(add_test_files)
|
function(add_test_files)
|
||||||
_add_files_tgt(openttd_test ${ARGV})
|
if(NOT OPTION_NO_SPLIT_LIB)
|
||||||
|
_add_files_tgt(openttd_test ${ARGV})
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# This function works around an 'issue' with CMake, where
|
# This function works around an 'issue' with CMake, where
|
||||||
|
|||||||
Reference in New Issue
Block a user