Skip to content

Commit 56d768c

Browse files
committed
Modernise Boost CMake stuff
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).
1 parent 6098f84 commit 56d768c

File tree

11 files changed

+19
-40
lines changed

11 files changed

+19
-40
lines changed

CI/before_script.msvc.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,7 @@ printf "Boost ${BOOST_VER}... "
713713
"${DEPS}/boost-${BOOST_VER}-msvc${MSVC_VER}-win${BITS}.exe" //DIR="${CWD_DRIVE_ROOT}" //VERYSILENT //NORESTART ${CI_EXTRA_INNO_OPTIONS}
714714
mv "${CWD_DRIVE_ROOT_BASH}" "${BOOST_SDK}"
715715
fi
716-
add_cmake_opts -DBOOST_ROOT="$BOOST_SDK" \
717-
-DBOOST_LIBRARYDIR="${BOOST_SDK}/lib${BITS}-msvc-${MSVC_VER}"
718-
add_cmake_opts -DBoost_COMPILER="-${TOOLSET}"
716+
BOOST_PREFIX="${BOOST_SDK}/lib${BITS}-msvc-${MSVC_VER}/cmake/Boost-1.80.0"
719717
echo Done.
720718
}
721719
cd $DEPS
@@ -1028,7 +1026,7 @@ printf "zlib 1.2.11... "
10281026
echo Done.
10291027
}
10301028

1031-
add_cmake_opts -DCMAKE_PREFIX_PATH="\"${QT_SDK};${SDL2DIR}\""
1029+
add_cmake_opts -DCMAKE_PREFIX_PATH="\"${QT_SDK};${SDL2DIR};${BOOST_PREFIX}\""
10321030

10331031
echo
10341032
cd $DEPS_INSTALL/..

CMakeLists.txt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ include(WholeArchive)
124124

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

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

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

370369
# Platform specific
371370
if (WIN32)
372-
if(NOT MINGW)
373-
set(Boost_USE_STATIC_LIBS ON)
374-
add_definitions(-DBOOST_ALL_NO_LIB)
375-
endif(NOT MINGW)
376-
377371
# Suppress WinMain(), provided by SDL
378372
add_definitions(-DSDL_MAIN_HANDLED)
379373

@@ -466,14 +460,7 @@ if(WIN32)
466460
endif(MSVC)
467461
endif(WIN32)
468462

469-
IF(BOOST_STATIC)
470-
set(Boost_USE_STATIC_LIBS ON)
471-
endif()
472-
473-
set(Boost_NO_BOOST_CMAKE ON)
474-
set(Boost_NO_WARN_NEW_VERSIONS ON) # ignore warnings about new releases of boost
475-
476-
find_package(Boost 1.6.2 REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS})
463+
find_package(Boost 1.70.0 CONFIG REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS})
477464

478465
if(OPENMW_USE_SYSTEM_MYGUI)
479466
find_package(MyGUI 3.4.3 REQUIRED)
@@ -502,7 +489,6 @@ set(SOL_CONFIG_DIR ${OpenMW_SOURCE_DIR}/extern/sol_config)
502489
include_directories(
503490
BEFORE SYSTEM
504491
"."
505-
${Boost_INCLUDE_DIR}
506492
${MyGUI_INCLUDE_DIRS}
507493
${OPENAL_INCLUDE_DIR}
508494
${OPENGL_INCLUDE_DIR}
@@ -513,7 +499,7 @@ include_directories(
513499
${ICU_INCLUDE_DIRS}
514500
)
515501

516-
link_directories(${Boost_LIBRARY_DIRS} ${COLLADA_DOM_LIBRARY_DIRS})
502+
link_directories(${COLLADA_DOM_LIBRARY_DIRS})
517503

518504
if(MYGUI_STATIC)
519505
add_definitions(-DMYGUI_STATIC)
@@ -601,7 +587,6 @@ endif()
601587

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

606591
if (APPLE)
607592
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")

apps/bsatool/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ openmw_add_executable(bsatool
99
)
1010

1111
target_link_libraries(bsatool
12-
${Boost_PROGRAM_OPTIONS_LIBRARY}
12+
Boost::program_options
1313
components
1414
)
1515

apps/bulletobjecttool/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ source_group(apps\\bulletobjecttool FILES ${BULLETMESHTOOL})
66
openmw_add_executable(openmw-bulletobjecttool ${BULLETMESHTOOL})
77

88
target_link_libraries(openmw-bulletobjecttool
9-
${Boost_PROGRAM_OPTIONS_LIBRARY}
9+
Boost::program_options
1010
components
1111
)
1212

apps/esmtool/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ openmw_add_executable(esmtool
1616
)
1717

1818
target_link_libraries(esmtool
19-
${Boost_PROGRAM_OPTIONS_LIBRARY}
19+
Boost::program_options
2020
components
2121
)
2222

apps/essimporter/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ openmw_add_executable(openmw-essimporter
3434
)
3535

3636
target_link_libraries(openmw-essimporter
37-
${Boost_PROGRAM_OPTIONS_LIBRARY}
37+
Boost::program_options
3838
components
3939
)
4040

apps/mwiniimporter/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ openmw_add_executable(openmw-iniimporter
1414
)
1515

1616
target_link_libraries(openmw-iniimporter
17-
${Boost_PROGRAM_OPTIONS_LIBRARY}
17+
Boost::program_options
1818
components
1919
)
2020

2121
if (WIN32)
2222
target_link_libraries(openmw-iniimporter
23-
${Boost_LOCALE_LIBRARY})
23+
Boost::locale)
2424
INSTALL(TARGETS openmw-iniimporter RUNTIME DESTINATION ".")
2525
endif(WIN32)
2626

apps/navmeshtool/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source_group(apps\\navmeshtool FILES ${NAVMESHTOOL})
88
openmw_add_executable(openmw-navmeshtool ${NAVMESHTOOL})
99

1010
target_link_libraries(openmw-navmeshtool
11-
${Boost_PROGRAM_OPTIONS_LIBRARY}
11+
Boost::program_options
1212
components
1313
)
1414

apps/opencs/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ target_link_libraries(openmw-cs-lib
244244
${OSGTEXT_LIBRARIES}
245245
${OSG_LIBRARIES}
246246
${EXTERN_OSGQT_LIBRARY}
247-
${Boost_PROGRAM_OPTIONS_LIBRARY}
247+
Boost::program_options
248248
components_qt
249249
)
250250

@@ -255,7 +255,7 @@ else()
255255
endif()
256256

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

apps/openmw/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ target_link_libraries(openmw-lib
159159
${OSGDB_LIBRARIES}
160160
${OSGUTIL_LIBRARIES}
161161
${OSG_LIBRARIES}
162-
${Boost_PROGRAM_OPTIONS_LIBRARY}
162+
Boost::program_options
163163
${OPENAL_LIBRARY}
164164
${FFmpeg_LIBRARIES}
165165
${MyGUI_LIBRARIES}

components/CMakeLists.txt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,9 @@ target_link_libraries(components
586586
${OSG_LIBRARIES}
587587
${OPENTHREADS_LIBRARIES}
588588

589-
${Boost_SYSTEM_LIBRARY}
590-
${Boost_PROGRAM_OPTIONS_LIBRARY}
591-
${Boost_IOSTREAMS_LIBRARY}
589+
Boost::system
590+
Boost::program_options
591+
Boost::iostreams
592592

593593
SDL2::SDL2
594594
${OPENGL_gl_LIBRARY}
@@ -612,16 +612,12 @@ else()
612612
target_link_libraries(components yaml-cpp)
613613
endif()
614614

615-
if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.77.0)
616-
target_link_libraries(components ${Boost_ATOMIC_LIBRARY})
617-
endif()
618-
619615
target_link_libraries(components ${BULLET_LIBRARIES})
620616

621617
if (WIN32)
622618
target_link_libraries(components
623-
${Boost_LOCALE_LIBRARY}
624-
${Boost_ZLIB_LIBRARY})
619+
Boost::locale
620+
Boost::zlib)
625621
endif()
626622

627623
if (USE_QT)

0 commit comments

Comments
 (0)