Skip to content

Commit

Permalink
build: Add flags to enable demo and tests
Browse files Browse the repository at this point in the history
Hiding these behind a flag prevents them from being build on other
projects
  • Loading branch information
rprospero committed Aug 16, 2024
1 parent 0333d62 commit cc4d3ac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,8 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
# Add main library subdir
add_subdirectory(src/)

enable_testing()
add_subdirectory(tests/)
option(BUILD_TESTS "Build test suite" OFF)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests/)
endif(BUILD_TESTS)
56 changes: 30 additions & 26 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,37 @@ set_target_properties(QuickPlot PROPERTIES PUBLIC_HEADER lineGeometry.h)

install(TARGETS QuickPlot QuickPlotplugin)

# Main target
qt_add_executable(demo main.cpp)
qt_add_qml_module(
demo
VERSION
1.0
URI
PlotDemo
QML_FILES
main.qml)
option(BUILD_DEMO "Build Demo Executable" OFF)
if(BUILD_DEMO)
# Main target
qt_add_executable(demo main.cpp)
qt_add_qml_module(
demo
VERSION
1.0
URI
PlotDemo
QML_FILES
main.qml)

target_include_directories(
demo
PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src
${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib
${Qt6Widgets_INCLUDE_DIRS} ${Qt6Quick3D_INCLUDE_DIRS})
target_include_directories(
demo
PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src
${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}/lib
${Qt6Widgets_INCLUDE_DIRS} ${Qt6Quick3D_INCLUDE_DIRS})

target_link_libraries(
demo
PRIVATE QuickPlot
QuickPlotplugin
Qt6::Widgets
Qt6::Gui
Qt6::Qml
Qt6::Core
Qt6::Quick3D)

target_link_libraries(
demo
PRIVATE QuickPlot
QuickPlotplugin
Qt6::Widgets
Qt6::Gui
Qt6::Qml
Qt6::Core
Qt6::Quick3D)
set_target_properties(demo PROPERTIES RUNTIME demo)

set_target_properties(demo PROPERTIES RUNTIME demo)
install(TARGETS demo RUNTIME)

install(TARGETS demo RUNTIME)
endif(BUILD_DEMO)

0 comments on commit cc4d3ac

Please sign in to comment.