mirror of
https://github.com/OpenMW/openmw.git
synced 2025-07-10 00:11:35 +00:00
Split openmw into binary and library
To make it possible to create a new binary for the tests by linking this library to it. Rename openmw-lib into openmw to have libopenmw.a on Linux. Do not rename it on Windows to avoid conflict with automatically generated lib for exe due to __declspec(dllexport) presence.
This commit is contained in:
parent
2e0e0f53b6
commit
9b0362fba8
1 changed files with 38 additions and 20 deletions
|
@ -1,22 +1,25 @@
|
|||
# local files
|
||||
set(GAME
|
||||
main.cpp
|
||||
set(OPENMW_SOURCES
|
||||
engine.cpp
|
||||
options.cpp
|
||||
)
|
||||
|
||||
set(OPENMW_RESOURCES
|
||||
${CMAKE_SOURCE_DIR}/files/windows/openmw.rc
|
||||
${CMAKE_SOURCE_DIR}/files/windows/openmw.exe.manifest
|
||||
)
|
||||
|
||||
if (ANDROID)
|
||||
set(GAME ${GAME} android_main.cpp)
|
||||
set(OPENMW_SOURCES ${OPENMW_SOURCES} android_main.cpp)
|
||||
endif()
|
||||
|
||||
set(GAME_HEADER
|
||||
set(OPENMW_HEADERS
|
||||
doc.hpp
|
||||
engine.hpp
|
||||
options.hpp
|
||||
profile.hpp
|
||||
)
|
||||
|
||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||
source_group(apps/openmw FILES main.cpp ${OPENMW_SOURCES} ${OPENMW_HEADERS} ${OPENMW_RESOURCES})
|
||||
|
||||
add_openmw_dir (mwrender
|
||||
actors objects renderingmanager animation rotatecontroller sky skyutil npcanimation esm4npcanimation vismask
|
||||
|
@ -120,16 +123,27 @@ add_openmw_dir (mwbase
|
|||
# Main executable
|
||||
|
||||
if (NOT ANDROID)
|
||||
openmw_add_executable(openmw
|
||||
add_library(openmw-lib STATIC
|
||||
${OPENMW_FILES}
|
||||
${GAME} ${GAME_HEADER}
|
||||
${APPLE_BUNDLE_RESOURCES}
|
||||
${OPENMW_SOURCES}
|
||||
)
|
||||
|
||||
# Otherwise linker fails with LNK1149 because main.cpp has __declspec(dllexport)
|
||||
if(NOT WIN32)
|
||||
set_target_properties(openmw-lib PROPERTIES OUTPUT_NAME openmw)
|
||||
endif()
|
||||
|
||||
openmw_add_executable(openmw
|
||||
${APPLE_BUNDLE_RESOURCES}
|
||||
${OPENMW_RESOURCES}
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(openmw openmw-lib)
|
||||
else ()
|
||||
add_library(openmw
|
||||
SHARED
|
||||
add_library(openmw-lib SHARED
|
||||
${OPENMW_FILES}
|
||||
${GAME} ${GAME_HEADER}
|
||||
${OPENMW_SOURCES}
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
@ -139,7 +153,7 @@ include_directories(
|
|||
${FFmpeg_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(openmw
|
||||
target_link_libraries(openmw-lib
|
||||
# CMake's built-in OSG finder does not use pkgconfig, so we have to
|
||||
# manually ensure the order is correct for inter-library dependencies.
|
||||
# This only makes a difference with `-DOPENMW_USE_SYSTEM_OSG=ON -DOSG_STATIC=ON`.
|
||||
|
@ -163,7 +177,7 @@ target_link_libraries(openmw
|
|||
)
|
||||
|
||||
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
|
||||
target_precompile_headers(openmw PRIVATE
|
||||
target_precompile_headers(openmw-lib PRIVATE
|
||||
<boost/program_options/options_description.hpp>
|
||||
|
||||
<sol/sol.hpp>
|
||||
|
@ -191,20 +205,20 @@ endif()
|
|||
add_definitions(-DMYGUI_DONT_USE_OBSOLETE=ON)
|
||||
|
||||
if (ANDROID)
|
||||
target_link_libraries(openmw EGL android log z)
|
||||
target_link_libraries(openmw-lib EGL android log z)
|
||||
endif (ANDROID)
|
||||
|
||||
if (USE_SYSTEM_TINYXML)
|
||||
target_link_libraries(openmw ${TinyXML_LIBRARIES})
|
||||
target_link_libraries(openmw-lib ${TinyXML_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if (NOT UNIX)
|
||||
target_link_libraries(openmw ${SDL2MAIN_LIBRARY})
|
||||
target_link_libraries(openmw-lib ${SDL2MAIN_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Fix for not visible pthreads functions for linker with glibc 2.15
|
||||
if (UNIX AND NOT APPLE)
|
||||
target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries(openmw-lib ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
@ -236,8 +250,12 @@ if(APPLE)
|
|||
endif(APPLE)
|
||||
|
||||
if (BUILD_WITH_CODE_COVERAGE)
|
||||
target_compile_options(openmw-lib PRIVATE --coverage)
|
||||
target_link_libraries(openmw-lib gcov)
|
||||
if (NOT ANDROID)
|
||||
target_compile_options(openmw PRIVATE --coverage)
|
||||
target_link_libraries(openmw gcov)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
|
|
Loading…
Reference in a new issue