Skip to content

Commit

Permalink
Modernise Boost CMake stuff
Browse files Browse the repository at this point in the history
Resolves https://gitlab.com/OpenMW/openmw/-/issues/8100

Also removes some old crud.
Hopefully the old crud is all:
* Handled automatically by CMake now we're using the modern approach.
* A hack-fix for a problem caused by not using the modern approach.
* Massively outdated so no longer necessary.

If it turns out this makes CI fail, I'll tweak things as necessary.

Changes that might not be wanted include:
* Getting rid of our BOOST_STATIC CMake option. In cases where the CMake config doesn't make the one correct choice from the build environment (i.e. because there's a choice) the CMake config exposes the option already.
  However, we were forcing this on for Windows, so that might matter.
  It seems to default to static on my machine even though I thought I read something suggesting otherwise, so we'll see how things go with that.
  If we eventually put CMake in charge of installing dependency DLLs this will be a moot point as we won't need to care.
* Bumping the minimum version of Boost to 1.70.0, as that's the first with working CMake config.
  It's from 2019, so plausibly there are distros too scared to use a library from five years ago as it can't legally drink in the US (although it could in limited quantities with parental supervision in the UK, as long as it's just something inconsequential like a single sip of beer).
  • Loading branch information
AnyOldName3 committed Aug 22, 2024
1 parent 6098f84 commit 56d768c
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 40 deletions.
6 changes: 2 additions & 4 deletions CI/before_script.msvc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,7 @@ printf "Boost ${BOOST_VER}... "
"${DEPS}/boost-${BOOST_VER}-msvc${MSVC_VER}-win${BITS}.exe" //DIR="${CWD_DRIVE_ROOT}" //VERYSILENT //NORESTART ${CI_EXTRA_INNO_OPTIONS}
mv "${CWD_DRIVE_ROOT_BASH}" "${BOOST_SDK}"
fi
add_cmake_opts -DBOOST_ROOT="$BOOST_SDK" \
-DBOOST_LIBRARYDIR="${BOOST_SDK}/lib${BITS}-msvc-${MSVC_VER}"
add_cmake_opts -DBoost_COMPILER="-${TOOLSET}"
BOOST_PREFIX="${BOOST_SDK}/lib${BITS}-msvc-${MSVC_VER}/cmake/Boost-1.80.0"
echo Done.
}
cd $DEPS
Expand Down Expand Up @@ -1028,7 +1026,7 @@ printf "zlib 1.2.11... "
echo Done.
}

add_cmake_opts -DCMAKE_PREFIX_PATH="\"${QT_SDK};${SDL2DIR}\""
add_cmake_opts -DCMAKE_PREFIX_PATH="\"${QT_SDK};${SDL2DIR};${BOOST_PREFIX}\""

echo
cd $DEPS_INSTALL/..
Expand Down
19 changes: 2 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ include(WholeArchive)

configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_BINARY_DIR}/docs/mainpage.hpp")

option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE)
option(QT_STATIC "Link static build of Qt into the binaries" FALSE)

option(OPENMW_USE_SYSTEM_BULLET "Use system provided bullet physics library" ON)
Expand Down Expand Up @@ -369,11 +368,6 @@ endif()

# Platform specific
if (WIN32)
if(NOT MINGW)
set(Boost_USE_STATIC_LIBS ON)
add_definitions(-DBOOST_ALL_NO_LIB)
endif(NOT MINGW)

# Suppress WinMain(), provided by SDL
add_definitions(-DSDL_MAIN_HANDLED)

Expand Down Expand Up @@ -466,14 +460,7 @@ if(WIN32)
endif(MSVC)
endif(WIN32)

IF(BOOST_STATIC)
set(Boost_USE_STATIC_LIBS ON)
endif()

set(Boost_NO_BOOST_CMAKE ON)
set(Boost_NO_WARN_NEW_VERSIONS ON) # ignore warnings about new releases of boost

find_package(Boost 1.6.2 REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS})
find_package(Boost 1.70.0 CONFIG REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS})

if(OPENMW_USE_SYSTEM_MYGUI)
find_package(MyGUI 3.4.3 REQUIRED)
Expand Down Expand Up @@ -502,7 +489,6 @@ set(SOL_CONFIG_DIR ${OpenMW_SOURCE_DIR}/extern/sol_config)
include_directories(
BEFORE SYSTEM
"."
${Boost_INCLUDE_DIR}
${MyGUI_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
Expand All @@ -513,7 +499,7 @@ include_directories(
${ICU_INCLUDE_DIRS}
)

link_directories(${Boost_LIBRARY_DIRS} ${COLLADA_DOM_LIBRARY_DIRS})
link_directories(${COLLADA_DOM_LIBRARY_DIRS})

if(MYGUI_STATIC)
add_definitions(-DMYGUI_STATIC)
Expand Down Expand Up @@ -601,7 +587,6 @@ endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(OPENMW_CXX_FLAGS "-Wall -Wextra -Wundef -Wextra-semi -Wno-unused-parameter -pedantic -Wno-long-long -Wnon-virtual-dtor -Wunused ${OPENMW_CXX_FLAGS}")
add_definitions( -DBOOST_NO_CXX11_SCOPED_ENUMS=ON )

if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
Expand Down
2 changes: 1 addition & 1 deletion apps/bsatool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ openmw_add_executable(bsatool
)

target_link_libraries(bsatool
${Boost_PROGRAM_OPTIONS_LIBRARY}
Boost::program_options
components
)

Expand Down
2 changes: 1 addition & 1 deletion apps/bulletobjecttool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source_group(apps\\bulletobjecttool FILES ${BULLETMESHTOOL})
openmw_add_executable(openmw-bulletobjecttool ${BULLETMESHTOOL})

target_link_libraries(openmw-bulletobjecttool
${Boost_PROGRAM_OPTIONS_LIBRARY}
Boost::program_options
components
)

Expand Down
2 changes: 1 addition & 1 deletion apps/esmtool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ openmw_add_executable(esmtool
)

target_link_libraries(esmtool
${Boost_PROGRAM_OPTIONS_LIBRARY}
Boost::program_options
components
)

Expand Down
2 changes: 1 addition & 1 deletion apps/essimporter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ openmw_add_executable(openmw-essimporter
)

target_link_libraries(openmw-essimporter
${Boost_PROGRAM_OPTIONS_LIBRARY}
Boost::program_options
components
)

Expand Down
4 changes: 2 additions & 2 deletions apps/mwiniimporter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ openmw_add_executable(openmw-iniimporter
)

target_link_libraries(openmw-iniimporter
${Boost_PROGRAM_OPTIONS_LIBRARY}
Boost::program_options
components
)

if (WIN32)
target_link_libraries(openmw-iniimporter
${Boost_LOCALE_LIBRARY})
Boost::locale)
INSTALL(TARGETS openmw-iniimporter RUNTIME DESTINATION ".")
endif(WIN32)

Expand Down
2 changes: 1 addition & 1 deletion apps/navmeshtool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source_group(apps\\navmeshtool FILES ${NAVMESHTOOL})
openmw_add_executable(openmw-navmeshtool ${NAVMESHTOOL})

target_link_libraries(openmw-navmeshtool
${Boost_PROGRAM_OPTIONS_LIBRARY}
Boost::program_options
components
)

Expand Down
4 changes: 2 additions & 2 deletions apps/opencs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ target_link_libraries(openmw-cs-lib
${OSGTEXT_LIBRARIES}
${OSG_LIBRARIES}
${EXTERN_OSGQT_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
Boost::program_options
components_qt
)

Expand All @@ -255,7 +255,7 @@ else()
endif()

if (WIN32)
target_link_libraries(openmw-cs-lib ${Boost_LOCALE_LIBRARY})
target_link_libraries(openmw-cs-lib Boost::locale)
target_sources(openmw-cs PRIVATE ${CMAKE_SOURCE_DIR}/files/windows/openmw-cs.exe.manifest)
endif()

Expand Down
2 changes: 1 addition & 1 deletion apps/openmw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ target_link_libraries(openmw-lib
${OSGDB_LIBRARIES}
${OSGUTIL_LIBRARIES}
${OSG_LIBRARIES}
${Boost_PROGRAM_OPTIONS_LIBRARY}
Boost::program_options
${OPENAL_LIBRARY}
${FFmpeg_LIBRARIES}
${MyGUI_LIBRARIES}
Expand Down
14 changes: 5 additions & 9 deletions components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ target_link_libraries(components
${OSG_LIBRARIES}
${OPENTHREADS_LIBRARIES}

${Boost_SYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_IOSTREAMS_LIBRARY}
Boost::system
Boost::program_options
Boost::iostreams

SDL2::SDL2
${OPENGL_gl_LIBRARY}
Expand All @@ -612,16 +612,12 @@ else()
target_link_libraries(components yaml-cpp)
endif()

if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.77.0)
target_link_libraries(components ${Boost_ATOMIC_LIBRARY})
endif()

target_link_libraries(components ${BULLET_LIBRARIES})

if (WIN32)
target_link_libraries(components
${Boost_LOCALE_LIBRARY}
${Boost_ZLIB_LIBRARY})
Boost::locale
Boost::zlib)
endif()

if (USE_QT)
Expand Down

0 comments on commit 56d768c

Please sign in to comment.