mirror of https://github.com/OpenTTD/OpenTTD
Codechange: split building into a library and executable
parent
9e89eb5726
commit
9b56505fec
|
@ -224,7 +224,8 @@ include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/squirrel/include)
|
||||||
|
|
||||||
include(MSVCFilters)
|
include(MSVCFilters)
|
||||||
|
|
||||||
add_executable(openttd WIN32 ${GENERATED_SOURCE_FILES})
|
add_library(openttd_lib OBJECT ${GENERATED_SOURCE_FILES})
|
||||||
|
add_executable(openttd WIN32)
|
||||||
set_target_properties(openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}")
|
set_target_properties(openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}")
|
||||||
# All other files are added via target_sources()
|
# All other files are added via target_sources()
|
||||||
|
|
||||||
|
@ -240,17 +241,21 @@ add_subdirectory(${CMAKE_SOURCE_DIR}/media)
|
||||||
add_dependencies(openttd
|
add_dependencies(openttd
|
||||||
find_version)
|
find_version)
|
||||||
|
|
||||||
target_link_libraries(openttd
|
target_link_libraries(openttd_lib
|
||||||
openttd::languages
|
openttd::languages
|
||||||
openttd::settings
|
openttd::settings
|
||||||
openttd::media
|
|
||||||
openttd::basesets
|
|
||||||
openttd::script_api
|
openttd::script_api
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_libraries(openttd
|
||||||
|
openttd_lib
|
||||||
|
openttd::media
|
||||||
|
openttd::basesets
|
||||||
|
)
|
||||||
|
|
||||||
if(HAIKU)
|
if(HAIKU)
|
||||||
target_link_libraries(openttd "be" "network" "midi")
|
target_link_libraries(openttd_lib "be" "network" "midi")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(IPO_FOUND)
|
if(IPO_FOUND)
|
||||||
|
@ -297,7 +302,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}
|
||||||
|
@ -376,7 +381,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)
|
||||||
|
|
|
@ -17,7 +17,7 @@ function(add_files)
|
||||||
endif()
|
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_lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,12 @@ add_files(
|
||||||
font_osx.h
|
font_osx.h
|
||||||
macos.h
|
macos.h
|
||||||
macos.mm
|
macos.mm
|
||||||
osx_main.cpp
|
|
||||||
osx_stdafx.h
|
osx_stdafx.h
|
||||||
string_osx.cpp
|
string_osx.cpp
|
||||||
string_osx.h
|
string_osx.h
|
||||||
CONDITION APPLE
|
CONDITION APPLE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/osx_main.cpp)
|
||||||
|
endif()
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
add_files(
|
add_files(
|
||||||
os2.cpp
|
os2.cpp
|
||||||
os2_main.cpp
|
|
||||||
CONDITION OPTION_OS2
|
CONDITION OPTION_OS2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(OPTION_OS2)
|
||||||
|
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/os2_main.cpp)
|
||||||
|
endif()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
add_files(
|
add_files(
|
||||||
crashlog_unix.cpp
|
crashlog_unix.cpp
|
||||||
unix_main.cpp
|
|
||||||
CONDITION UNIX AND NOT APPLE AND NOT OPTION_OS2
|
CONDITION UNIX AND NOT APPLE AND NOT OPTION_OS2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,3 +12,7 @@ add_files(
|
||||||
font_unix.cpp
|
font_unix.cpp
|
||||||
CONDITION Fontconfig_FOUND
|
CONDITION Fontconfig_FOUND
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(UNIX AND NOT APPLE AND NOT OPTION_OS2)
|
||||||
|
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/unix_main.cpp)
|
||||||
|
endif()
|
||||||
|
|
|
@ -6,6 +6,9 @@ add_files(
|
||||||
string_uniscribe.h
|
string_uniscribe.h
|
||||||
win32.cpp
|
win32.cpp
|
||||||
win32.h
|
win32.h
|
||||||
win32_main.cpp
|
|
||||||
CONDITION WIN32
|
CONDITION WIN32
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/win32_main.cpp)
|
||||||
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue