Changeset - r27101:890608293788
[Not reviewed]
master
0 8 0
Rubidium - 13 months ago 2023-04-10 16:00:53
rubidium@openttd.org
Codechange: split building into a library and executable
8 files changed with 32 insertions and 15 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -224,7 +224,8 @@ include_directories(${CMAKE_SOURCE_DIR}/
 

	
 
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}")
 
# All other files are added via target_sources()
 

	
 
@@ -240,17 +241,21 @@ add_subdirectory(${CMAKE_SOURCE_DIR}/med
 
add_dependencies(openttd
 
    find_version)
 

	
 
target_link_libraries(openttd
 
target_link_libraries(openttd_lib
 
    openttd::languages
 
    openttd::settings
 
    openttd::media
 
    openttd::basesets
 
    openttd::script_api
 
    Threads::Threads
 
)
 

	
 
target_link_libraries(openttd
 
    openttd_lib
 
    openttd::media
 
    openttd::basesets
 
)
 

	
 
if(HAIKU)
 
    target_link_libraries(openttd "be" "network" "midi")
 
    target_link_libraries(openttd_lib "be" "network" "midi")
 
endif()
 

	
 
if(IPO_FOUND)
 
@@ -297,7 +302,7 @@ include(CheckAtomic)
 
if(APPLE)
 
    link_package(Iconv TARGET Iconv::Iconv)
 

	
 
    target_link_libraries(openttd
 
    target_link_libraries(openttd_lib
 
        ${AUDIOTOOLBOX_LIBRARY}
 
        ${AUDIOUNIT_LIBRARY}
 
        ${COCOA_LIBRARY}
 
@@ -376,7 +381,7 @@ if(WIN32)
 
        -DPSAPI_VERSION=1
 
    )
 

	
 
    target_link_libraries(openttd
 
    target_link_libraries(openttd_lib
 
        ws2_32
 
        winmm
 
        imm32
cmake/CheckAtomic.cmake
Show inline comments
 
@@ -83,5 +83,5 @@ else()
 
endif()
 

	
 
if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB)
 
  target_link_libraries(openttd atomic)
 
  target_link_libraries(openttd_lib atomic)
 
endif()
cmake/LinkPackage.cmake
Show inline comments
 
@@ -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.
 
        if(LP_TARGET AND 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}")
 
        else()
 
            string(STRIP "${${NAME}_LIBRARY}" ${NAME}_LIBRARY)
 
            string(STRIP "${${NAME}_LIBRARIES}" ${NAME}_LIBRARIES)
 
            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}")
 
        endif()
 
    elseif(LP_ENCOURAGED)
cmake/SourceList.cmake
Show inline comments
 
@@ -17,7 +17,7 @@ function(add_files)
 
    endif()
 

	
 
    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()
 
endfunction()
 

	
src/os/macosx/CMakeLists.txt
Show inline comments
 
@@ -4,9 +4,12 @@ add_files(
 
    font_osx.h
 
    macos.h
 
    macos.mm
 
    osx_main.cpp
 
    osx_stdafx.h
 
    string_osx.cpp
 
    string_osx.h
 
    CONDITION APPLE
 
)
 

	
 
if(APPLE)
 
    target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/osx_main.cpp)
 
endif()
src/os/os2/CMakeLists.txt
Show inline comments
 
add_files(
 
    os2.cpp
 
    os2_main.cpp
 
    CONDITION OPTION_OS2
 
)
 

	
 
if(OPTION_OS2)
 
    target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/os2_main.cpp)
 
endif()
src/os/unix/CMakeLists.txt
Show inline comments
 
add_files(
 
    crashlog_unix.cpp
 
    unix_main.cpp
 
    CONDITION UNIX AND NOT APPLE AND NOT OPTION_OS2
 
)
 

	
 
@@ -13,3 +12,7 @@ add_files(
 
    font_unix.cpp
 
    CONDITION Fontconfig_FOUND
 
)
 

	
 
if(UNIX AND NOT APPLE AND NOT OPTION_OS2)
 
    target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/unix_main.cpp)
 
endif()
src/os/windows/CMakeLists.txt
Show inline comments
 
@@ -6,6 +6,9 @@ add_files(
 
    string_uniscribe.h
 
    win32.cpp
 
    win32.h
 
    win32_main.cpp
 
    CONDITION WIN32
 
)
 

	
 
if(WIN32)
 
    target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/win32_main.cpp)
 
endif()
0 comments (0 inline, 0 general)