Skip to content

Commit

Permalink
-- demos: fix building against binary packages
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusBgm committed Sep 21, 2022
1 parent 493708f commit f181ed5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
35 changes: 24 additions & 11 deletions Demos/CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,26 @@ if(NOT TARGET SilKit)
# Assuming we are standalone but still within the original distribution directory layout
# so the source release should be located in ../${INSTALL_SOURCE_DIR}
message(STATUS "<-> no SilKit-Library target found. working in distribution mode")
message(STATUS "<-> using deployed SIL Kit")
# NB: As of SIL Kit 3.0.2, FMT is optional
include(
${CMAKE_CURRENT_LIST_DIR}/../SilKit-Source/ThirdParty/fmt.cmake
OPTIONAL)
message(STATUS "<-> Using a prebuilt SIL Kit package. If find_package fails,"
" please specify SILKIT_DIR to provide a look up hint.")

file(GLOB _glob_silkit_dir LIST_DIRECTORIES true
"${CMAKE_CURRENT_LIST_DIR}/../../SilKit-*.*.*-*-*-*/include/"
)
set(silkitDirs)
foreach(path IN LISTS _glob_silkit_dir)
list(APPEND silkitDirs "${path}/..")
endforeach()

find_package(SilKit
REQUIRED
CONFIG
NO_CMAKE_PACKAGE_REGISTRY
NO_DEFAULT_PATH
PATHS "${CMAKE_CURRENT_LIST_DIR}/../SilKit"
PATHS
"${CMAKE_CURRENT_LIST_DIR}/../SilKit"
"${SILKIT_DIR}"
${silkitDirs}
)
set(_is_standalone TRUE)
else()
Expand Down Expand Up @@ -79,15 +88,19 @@ add_custom_target(Demos COMMENT "Build all available Demos")
set_property(TARGET Demos PROPERTY FOLDER "Demos")

# Generate SIL Kit Demo Project

if(_is_standalone)
get_target_property(silkitImportLocation SilKit::SilKit IMPORTED_LOCATION_RELEASE)
get_filename_component(silkitLibDir "${silkitImportLocation}" DIRECTORY)
set(_DEMO_OUTPUT_DIR "${silkitLibDir}/../bin")
else()
set(_DEMO_OUTPUT_DIR "${CMAKE_BINARY_DIR}/$<CONFIG>")
endif()

macro(make_silkit_demo executableName demoSourceFile)
add_executable(${executableName}
${demoSourceFile}
)
if(_is_standalone)
set(_DEMO_OUTPUT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../SilKit/bin")
else()
set(_DEMO_OUTPUT_DIR "${CMAKE_BINARY_DIR}/$<CONFIG>")
endif()
remove_definitions(-DEXPORT_SilKitAPI)

# Group this demo project into a folder
Expand Down
22 changes: 16 additions & 6 deletions Demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,28 @@ Supported target platforms and build tools:

## Build Instructions

For the binary release, the cmake build from the 'SilKit-Demos'
For the binary distribution, the cmake build from the 'SilKit-Demos'
directory should work on all supported platforms in a similar way:

> mkdir build
> cmake -B build
> cd build
> cmake --build build
> cmake ../
You might want to add the appropriate '-T toolset' and '-A architecture' options on MSVC builds.
The demos will be placed alongside the binaries, if the binary distribution is unpacked next
to the SilKit-Source package.
For example, if the directory layout looks as follows, the demo executables will
be placed in `SilKit-X.Y.Z-$Platform/bin`:

> cmake --build .
> SilKit-X.Y.Z-Source/Demos
> SilKit-X.Y.Z-$Platform/

You can also specify the location of the unpacked binary package using the `SILKIT_DIR` variable:

> cmake -B build -D SILKIT_DIR=path/to/SilKit-X.Y.Z-PlatformEtc
The demos will be placed alongside the binaries.

To build the demos as developer from within the SIL Kit source tree and place them alongside
the binaries, build the 'Demos' CMake target from the SIL Kit 'build' directory:
Expand Down

0 comments on commit f181ed5

Please sign in to comment.