Skip to content

Commit

Permalink
CMake install targets
Browse files Browse the repository at this point in the history
  • Loading branch information
dancazarin committed Oct 25, 2024
1 parent ff0f747 commit f160115
Show file tree
Hide file tree
Showing 21 changed files with 427 additions and 293 deletions.
63 changes: 49 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,18 @@ jobs:
vcpkg install --x-install-root vcpkg_installed --x-feature=icu
- name: Configure
run: |
cmake -GNinja -S . -B build -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_C_COMPILER=clang-19
cmake -GNinja -S . -B build -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_C_COMPILER=clang-19
- name: Build
run: |
cmake --build build
cmake --build build --target install
- name: Test
run: |
WGPU_LONG_TIMEOUT=1 ctest --test-dir build --output-on-failure -E "window_autotests"
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/dist

ubuntu-make-gcc-x86_64:
runs-on: ubuntu-24.04
Expand All @@ -55,13 +60,18 @@ jobs:
vcpkg install --x-install-root vcpkg_installed --x-feature=icu
- name: Configure
run: |
cmake -G"Unix Makefiles" -S . -B build -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14
cmake -G"Unix Makefiles" -S . -B build -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14
- name: Build
run: |
cmake --build build
cmake --build build --target install
- name: Test
run: |
WGPU_LONG_TIMEOUT=1 ctest --test-dir build --output-on-failure -E "window_autotests"
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/dist

windows-ninja-clang-x86-64:
runs-on: windows-latest
Expand All @@ -82,13 +92,18 @@ jobs:
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cmake -GNinja -S . -B build -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET% -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_LINKER="C:/Program Files/LLVM/bin/lld-link.exe"
cmake -GNinja -S . -B build -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET% -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_LINKER="C:/Program Files/LLVM/bin/lld-link.exe"
- name: Build
run: |
cmake --build build
cmake --build build --target install
- name: Test
run: |
ctest --test-dir build --output-on-failure
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/dist

windows-vs-x86:
runs-on: windows-latest
Expand All @@ -104,13 +119,18 @@ jobs:
- name: Configure
shell: cmd
run: |
cmake -G"Visual Studio 17 2022" -A Win32 -S . -B build -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET% -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON
cmake -G"Visual Studio 17 2022" -A Win32 -S . -B build -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET% -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON
- name: Build
run: |
cmake --build build --config RelWithDebInfo
cmake --build build --config RelWithDebInfo --target install
- name: Test
run: |
ctest --test-dir build --build-config RelWithDebInfo --output-on-failure
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/dist

windows-vs-clangcl-x86_64:
runs-on: windows-latest
Expand All @@ -126,13 +146,18 @@ jobs:
- name: Configure
shell: cmd
run: |
cmake -G"Visual Studio 17 2022" -A x64 -T ClangCL -S . -B build -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET% -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON
cmake -G"Visual Studio 17 2022" -A x64 -T ClangCL -S . -B build -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DVCPKG_TARGET_TRIPLET=%VCPKG_DEFAULT_TRIPLET% -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON
- name: Build
run: |
cmake --build build --config RelWithDebInfo
cmake --build build --config RelWithDebInfo --target install
- name: Test
run: |
ctest --test-dir build --build-config RelWithDebInfo --output-on-failure
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/dist

macos-ninja-clang-arm64:
runs-on: macos-latest
Expand All @@ -154,13 +179,18 @@ jobs:
- name: Configure
run: |
export VCPKG_ROOT="$HOME/vcpkg"
cmake -GNinja -S . -B build -DVCPKG_MANIFEST_MODE=OFF -DCMAKE_OSX_ARCHITECTURES=arm64 -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake -GNinja -S . -B build -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DCMAKE_OSX_ARCHITECTURES=arm64 -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
- name: Build
run: |
cmake --build build
cmake --build build --target install
- name: Test
run: |
ctest --test-dir build --output-on-failure
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/dist

macos-ninja-clang-x86_64:
runs-on: macos-13
Expand All @@ -182,10 +212,15 @@ jobs:
- name: Configure
run: |
export VCPKG_ROOT="$HOME/vcpkg"
cmake -GNinja -S . -B build -DVCPKG_MANIFEST_MODE=OFF -DCMAKE_OSX_ARCHITECTURES=x86_64 -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake -GNinja -S . -B build -DCMAKE_INSTALL_PREFIX=dist -DVCPKG_MANIFEST_MODE=OFF -DCMAKE_OSX_ARCHITECTURES=x86_64 -DVCPKG_INSTALLED_DIR=vcpkg_installed -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DBRISK_LOG_TO_STDERR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
- name: Build
run: |
cmake --build build
cmake --build build --target install
- name: Test
run: |
ctest --test-dir build --output-on-failure
- name: Binaries
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/dist
119 changes: 105 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
#
# This file is part of the Brisk library.
#
# Brisk is dual-licensed under the GNU General Public License, version 2 (GPL-2.0+),
# and a commercial license. You may use, modify, and distribute this software under
# the terms of the GPL-2.0+ license if you comply with its conditions.
# Brisk is dual-licensed under the GNU General Public License, version 2 (GPL-2.0+), and a commercial license. You may
# use, modify, and distribute this software under the terms of the GPL-2.0+ license if you comply with its conditions.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <http://www.gnu.org/licenses/>.
# You should have received a copy of the GNU General Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
# If you do not wish to be bound by the GPL-2.0+ license, you must purchase a commercial
# license. For commercial licensing options, please visit: https://brisklib.com
# If you do not wish to be bound by the GPL-2.0+ license, you must purchase a commercial license. For commercial
# licensing options, please visit: https://brisklib.com
#

cmake_minimum_required(VERSION 3.16)
Expand All @@ -29,7 +28,23 @@ endif ()

include(cmake/init.cmake)

project(brisk CXX C)
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/include/brisk/core/Version.hpp BRISK_VERSION
REGEX "#define BRISK_VERSION_(MINOR|MAJOR|PATCH)")
string(REGEX MATCHALL "[0-9]+" BRISK_VERSION_MATCH ${BRISK_VERSION})
string(REPLACE ";" "." BRISK_VERSION "${BRISK_VERSION_MATCH}")

project(
brisk
VERSION ${BRISK_VERSION}
LANGUAGES CXX C)

if (DEBUG_CMAKE)
get_cmake_property(VARS VARIABLES)
list(SORT VARS)
foreach (VAR ${VARS})
message(STATUS "${VAR}=${${VAR}}")
endforeach ()
endif ()

option(BRISK_LTO ON "Use Link Time Optimization in Release builds")
option(BRISK_BROTLI "Enable Brotli compression" ON)
Expand Down Expand Up @@ -80,17 +95,19 @@ endif ()

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/licenses.txt" "")

set(_BRISK_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

include(GNUInstallDirs)

include(cmake/add_autotests.cmake)
include(cmake/compile_resources.cmake)
include(cmake/setup_executable.cmake)
include(cmake/metadata.cmake)
include(cmake/scripts/compile_resources.cmake)
include(cmake/scripts/setup_executable.cmake)
include(cmake/scripts/metadata.cmake)

if (BRISK_LOG_TO_STDERR)
add_compile_definitions(BRISK_LOG_TO_STDERR=1)
endif ()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

include(cmake/add_license.cmake)

file(GLOB_RECURSE LICENSE_LIST ${DEPS_DIR}/share/copyright) # CONFIGURE_DEPENDS
Expand All @@ -105,11 +122,21 @@ set(RESOURCES_DIR ${PROJECT_SOURCE_DIR}/resources)
set(FONTS_DIR ${RESOURCES_DIR}/fonts)
set(IMAGES_DIR ${RESOURCES_DIR}/images)

if (NOT BRISK_DBG_SUFFIX)
set(BRISK_DBG_SUFFIX
"/debug"
CACHE STRING "")
endif ()

add_subdirectory(src)

add_library(brisk-executable INTERFACE)
if (WIN32)
target_sources(brisk-executable INTERFACE src/window/default.manifest)
target_sources(
brisk-executable
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>$<INSTALL_INTERFACE:$<INSTALL_PREFIX>>/include/brisk/window/internal/Windows.manifest
)
endif ()

set(TESTS_GRAPHICS_LIBS)
Expand Down Expand Up @@ -157,3 +184,67 @@ if (BRISK_EXAMPLES)
add_subdirectory(examples)

endif ()

install(DIRECTORY include/brisk DESTINATION include)

include(CMakePackageConfigHelpers)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/BriskConfigVersion.cmake
VERSION ${BRISK_VERSION}
COMPATIBILITY SameMinorVersion)

set(BRISK_INSTALL_CMAKEDIR
"${CMAKE_INSTALL_LIBDIR}/cmake/brisk"
CACHE STRING "Path to Brisk CMake files")

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/BriskConfigVersion.cmake DESTINATION ${BRISK_INSTALL_CMAKEDIR})

configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/BriskConfig.cmake INSTALL_DESTINATION "lib/cmake/brisk")

set(EXTRA_INSTALL_TARGETS)

if (TARGET brisk-renderer-d3d11)
list(APPEND EXTRA_INSTALL_TARGETS brisk-renderer-d3d11)
endif ()
if (TARGET brisk-renderer-webgpu)
list(APPEND EXTRA_INSTALL_TARGETS brisk-renderer-webgpu)
endif ()
if (TARGET icowriter)
list(APPEND EXTRA_INSTALL_TARGETS icowriter)
endif ()

install(
TARGETS
brisk-core
brisk-graphics
brisk-network
brisk-window
brisk-gui
brisk-widgets
brisk-executable
bin2c
${EXTRA_INSTALL_TARGETS}
EXPORT BriskTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}$<$<CONFIG:Debug>:${BRISK_DBG_SUFFIX}>
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}$<$<CONFIG:Debug>:${BRISK_DBG_SUFFIX}>
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}$<$<CONFIG:Debug>:${BRISK_DBG_SUFFIX}>)

install(DIRECTORY cmake/scripts/ DESTINATION "${BRISK_INSTALL_CMAKEDIR}/scripts")

install(
FILES src/core/Deps.cmake
RENAME Core.cmake
DESTINATION "${BRISK_INSTALL_CMAKEDIR}/deps")
install(
FILES src/graphics/Deps.cmake
RENAME Graphics.cmake
DESTINATION "${BRISK_INSTALL_CMAKEDIR}/deps")

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/BriskConfig.cmake DESTINATION "${BRISK_INSTALL_CMAKEDIR}")

install(
EXPORT BriskTargets
DESTINATION "${BRISK_INSTALL_CMAKEDIR}"
CONFIGURATIONS Debug Release)
26 changes: 26 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@PACKAGE_INIT@

include(${CMAKE_CURRENT_LIST_DIR}/BriskTargets.cmake)

include(${CMAKE_CURRENT_LIST_DIR}/BriskConfigVersion.cmake)

get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_BRISK_INCLUDE_DIR "${_DIR}/../../../include" ABSOLUTE)

file(GLOB SCRIPT_FILES "${_DIR}/scripts/*.cmake")
foreach (f ${SCRIPT_FILES})
include(${f})
endforeach ()

include(CMakeFindDependencyMacro)

set(_DEP_PUBLIC INTERFACE)
set(_DEP_PRIVATE INTERFACE)
set(_FIND_PACKAGE find_dependency)

include(${_DIR}/deps/Core.cmake)
include(${_DIR}/deps/Graphics.cmake)

unset(_DEP_PUBLIC)
unset(_DEP_PRIVATE)
unset(_FIND_PACKAGE)
12 changes: 0 additions & 12 deletions cmake/packages/FindLibTomCrypt.cmake

This file was deleted.

12 changes: 0 additions & 12 deletions cmake/packages/FindLibTomMath.cmake

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function (setup_executable_platform TARGET)
set(HAS_ICON 0)
endif ()

configure_file(${brisk_SOURCE_DIR}/include/brisk/application/main/app.rc.in
configure_file(${_BRISK_INCLUDE_DIR}/brisk/application/main/app.rc.in
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.app.rc @ONLY)
if (NOT BRISK_FORCE_CONSOLE)
set_target_properties(${TARGET} PROPERTIES WIN32_EXECUTABLE TRUE)
Expand All @@ -47,5 +47,5 @@ function (setup_executable_platform TARGET)
endif ()

target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.app.rc)
target_sources(${TARGET} PRIVATE ${brisk_SOURCE_DIR}/include/brisk/application/main/Main_Windows.cpp)
target_sources(${TARGET} PRIVATE ${_BRISK_INCLUDE_DIR}/brisk/application/main/Main_Windows.cpp)
endfunction ()
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ function (brisk_target_link_resource TARGET MODE NAME)
set_source_files_properties(${DATA} ${HDR} PROPERTIES GENERATED TRUE)

target_sources(${TARGET} PRIVATE ${DATA} ${HDR})
target_include_directories(${TARGET} ${MODE} ${_RESOURCES_DIR})
target_include_directories(${TARGET} ${MODE} $<BUILD_INTERFACE:${_RESOURCES_DIR}>)
target_compile_definitions(${TARGET} PRIVATE BRISK_RESOURCE_${CNAME}=1)
endfunction ()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ function (brisk_setup_executable TARGET)
set(APP_VERSION_PATCH 0)
endif ()

configure_file(${brisk_SOURCE_DIR}/include/brisk/application/main/Metadata.Defines.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_meta/Metadata.Defines.hpp @ONLY)
set(APP_METADATA_FILE ${_BRISK_INCLUDE_DIR}/brisk/application/main/Metadata.Defines.hpp.in)

configure_file(${APP_METADATA_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_meta/Metadata.Defines.hpp @ONLY)
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_meta)

set_target_properties(
Expand Down
Loading

0 comments on commit f160115

Please sign in to comment.