From d3df3efaf191a1554a32100c41fa18a22c689858 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Sat, 4 Dec 2021 11:32:39 +0000 Subject: [PATCH] Precompile sol.hpp in order to reduce compilation time. --- CMakeLists.txt | 6 ++++-- apps/openmw/CMakeLists.txt | 5 ++++- apps/openmw/android_main.cpp | 2 ++ apps/openmw_test_suite/CMakeLists.txt | 2 +- components/CMakeLists.txt | 5 +++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 067b645a39..3f19b2a54f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,7 +414,8 @@ else(USE_LUAJIT) endif(USE_LUAJIT) # C++ library binding to Lua -set(SOL_INCLUDE_DIRS ${OpenMW_SOURCE_DIR}/extern/sol3.2.2 ${OpenMW_SOURCE_DIR}/extern/sol_config) +set(SOL_INCLUDE_DIR ${OpenMW_SOURCE_DIR}/extern/sol3.2.2) +set(SOL_CONFIG_DIR ${OpenMW_SOURCE_DIR}/extern/sol_config) include_directories( BEFORE SYSTEM @@ -426,7 +427,8 @@ include_directories( ${OPENGL_INCLUDE_DIR} ${BULLET_INCLUDE_DIRS} ${LUA_INCLUDE_DIR} - ${SOL_INCLUDE_DIRS} + ${SOL_INCLUDE_DIR} + ${SOL_CONFIG_DIR} ) link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS}) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 2582b272cf..551c68ce11 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -153,9 +153,12 @@ target_link_libraries(openmw "osg-ffmpeg-videoplayer" "oics" components - ${LUA_LIBRARIES} ) +if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) + target_precompile_headers(openmw PRIVATE ${SOL_INCLUDE_DIR}/sol/sol.hpp) +endif () + if (ANDROID) target_link_libraries(openmw EGL android log z) endif (ANDROID) diff --git a/apps/openmw/android_main.cpp b/apps/openmw/android_main.cpp index cc36388b0b..95365915df 100644 --- a/apps/openmw/android_main.cpp +++ b/apps/openmw/android_main.cpp @@ -1,4 +1,6 @@ +#ifndef stderr int stderr = 0; // Hack: fix linker error +#endif #include "SDL_main.h" #include diff --git a/apps/openmw_test_suite/CMakeLists.txt b/apps/openmw_test_suite/CMakeLists.txt index ed1d6c413b..7cfac20421 100644 --- a/apps/openmw_test_suite/CMakeLists.txt +++ b/apps/openmw_test_suite/CMakeLists.txt @@ -70,7 +70,7 @@ if (GTEST_FOUND AND GMOCK_FOUND) openmw_add_executable(openmw_test_suite openmw_test_suite.cpp ${UNITTEST_SRC_FILES}) - target_link_libraries(openmw_test_suite ${GMOCK_LIBRARIES} components ${LUA_LIBRARIES}) + target_link_libraries(openmw_test_suite ${GMOCK_LIBRARIES} components) # Fix for not visible pthreads functions for linker with glibc 2.15 if (UNIX AND NOT APPLE) target_link_libraries(openmw_test_suite ${CMAKE_THREAD_LIBS_INIT}) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index bdb22f2dc5..43f0fb1ab5 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -283,6 +283,7 @@ target_link_libraries(components ${SDL2_LIBRARIES} ${OPENGL_gl_LIBRARY} ${MyGUI_LIBRARIES} + ${LUA_LIBRARIES} LZ4::LZ4 RecastNavigation::DebugUtils RecastNavigation::Detour @@ -371,3 +372,7 @@ endif(OSG_STATIC) if(USE_QT) set_property(TARGET components_qt PROPERTY AUTOMOC ON) endif(USE_QT) + +if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) + target_precompile_headers(components PRIVATE ${SOL_INCLUDE_DIR}/sol/sol.hpp) +endif ()