Skip to content

Commit

Permalink
Better handling of multiple configurations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jul 10, 2024
1 parent 2388ed3 commit ebfb343
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,31 @@ jobs:
"-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64" `
"-DCMAKE_INSTALL_PREFIX=install" -DUIBASE_TESTING=ON
# build both Debug and RelWithDebInfo for package
- name: Build UI Base
run: cmake --build vsbuild --config RelWithDebInfo --target uibase-tests --verbose
run: |
cmake --build vsbuild --config Debug --target uibase-tests --verbose
cmake --build vsbuild --config RelWithDebInfo --target uibase-tests --verbose
- name: Test UI Base
run: ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
run: |
ctest --test-dir vsbuild -C Debug --output-on-failure
ctest --test-dir vsbuild -C RelWithDebInfo --output-on-failure
- name: Install UI Base
run: cmake --install vsbuild --config RelWithDebInfo
run: |
cmake --install vsbuild --config Debug
cmake --install vsbuild --config RelWithDebInfo
# this tests that UI Base can be properly used as a CMake package
- name: Test UI Base package
run: |
cmake -B build . "-DCMAKE_PREFIX_PATH=${env:QT_ROOT_DIR}\msvc2019_64;..\..\install\lib\cmake\"
cmake --build build --config Debug
cmake --build build --config Release
cmake --build build --config RelWithDebInfo
working-directory: tests/cmake


- name: Upload UI Base artifact
uses: actions/upload-artifact@master
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ CMakeLists.txt.user
/*build
/src/uibasetests_en.ts
/install
/tests/cmake/build
21 changes: 21 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ find_package(Qt6 CONFIG REQUIRED COMPONENTS Network QuickWidgets Widgets)

include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-uibase-targets.cmake" )

get_target_property(_UIBASE_CONFIGURATIONS mo2::uibase IMPORTED_CONFIGURATIONS)

# uibase is usually be build in Debug or Release/RelWithDebInfo, so we need to map
# missing configurations to avoid issue with CMP0111
list(FIND _UIBASE_CONFIGURATIONS "RELEASE" _UIBASE_HAS_RELEASE)
if (_UIBASE_HAS_RELEASE EQUAL -1)
set_target_properties(mo2::uibase PROPERTIES
MAP_IMPORTED_CONFIG_MINSIZEREL RelWithDebInfo
MAP_IMPORTED_CONFIG_RELEASE RelWithDebInfo
)
set_property(TARGET mo2::uibase APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
set_property(TARGET mo2::uibase APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
else()
set_target_properties(mo2::uibase PROPERTIES
MAP_IMPORTED_CONFIG_MINSIZEREL Release
MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
)
set_property(TARGET mo2::uibase APPEND PROPERTY IMPORTED_CONFIGURATIONS MINSIZEREL)
set_property(TARGET mo2::uibase APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO)
endif()

if (MO2_CMAKE_DEPRECATED_UIBASE_INCLUDE)
target_include_directories(mo2::uibase INTERFACE
${_UIBASE_PREFIX_DIR}/include/uibase ${_UIBASE_PREFIX_DIR}/include/uibase/game_features)
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ target_sources(uibase
FILES ${uibase_headers}
)

set_target_properties(uibase PROPERTIES DEBUG_POSTFIX d)

# TODO: remove this after fixing UIBase #include<> directives
target_include_directories(uibase PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/uibase>
Expand Down
9 changes: 9 additions & 0 deletions tests/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.16)

project(uibase-tests-cmake)

find_package(mo2-uibase CONFIG REQUIRED)

add_library(plugin SHARED)
target_sources(plugin PRIVATE plugin.cpp)
target_link_libraries(plugin PRIVATE mo2::uibase)
4 changes: 4 additions & 0 deletions tests/cmake/plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <uibase/iplugin.h>

class Plugin : public MOBase::IPlugin
{};

0 comments on commit ebfb343

Please sign in to comment.