Make it easier to run the examples on Windows in the C++ build

Place the examples into the bin folder in the top-level directory (when
not built standalone), along with the sixtyfps dll.
This commit is contained in:
Simon Hausmann 2021-06-01 10:05:00 +02:00
parent 5b9ce15ae2
commit 5d24fde6f5
2 changed files with 12 additions and 0 deletions

View file

@ -12,6 +12,12 @@ cmake_minimum_required(VERSION 3.16)
project(SixtyFPS LANGUAGES CXX) project(SixtyFPS LANGUAGES CXX)
include(CTest) include(CTest)
# Place all compiled examples into the same bin directory
# on Windows, where we'll also put the dll
if (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()
add_subdirectory(api/sixtyfps-cpp/) add_subdirectory(api/sixtyfps-cpp/)
add_subdirectory(examples/printerdemo/cpp/) add_subdirectory(examples/printerdemo/cpp/)
add_subdirectory(examples/printerdemo/cpp_interpreted/) add_subdirectory(examples/printerdemo/cpp_interpreted/)

View file

@ -104,6 +104,12 @@ include(GNUInstallDirs)
install(FILES $<TARGET_FILE:sixtyfps-cpp-shared> TYPE LIB) install(FILES $<TARGET_FILE:sixtyfps-cpp-shared> TYPE LIB)
if(WIN32) if(WIN32)
install(FILES $<TARGET_LINKER_FILE:sixtyfps-cpp-shared> TYPE LIB) install(FILES $<TARGET_LINKER_FILE:sixtyfps-cpp-shared> TYPE LIB)
# Copy the dll to the top-level bin directory, where the examples will
# will also be located, so that they can find the dll.
add_custom_target(SixtyFPS_dll_convenience ALL DEPENDS sixtyfps-cpp-shared
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:sixtyfps-cpp-shared>
${CMAKE_BINARY_DIR}/bin/$<TARGET_FILE_NAME:sixtyfps-cpp-shared>)
endif() endif()
install(PROGRAMS $<TARGET_FILE:sixtyfps_compiler> TYPE BIN) install(PROGRAMS $<TARGET_FILE:sixtyfps_compiler> TYPE BIN)