Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Commit

Permalink
build: disable install when project is not top
Browse files Browse the repository at this point in the history
Signed-off-by: black-desk <[email protected]>
  • Loading branch information
black-desk committed Jul 21, 2023
1 parent 40598d9 commit 1c4a600
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,35 @@ project (
CXX
)

# cmake-format: off
set (
QSERIALIZER_QT_VERSION_MAJOR "6"
CACHE STRING "The qt major version tests and examples link to."
)

set (
QSERIALIZER_ENABLE_TESTING ${PROJECT_IS_TOP_LEVEL}
CACHE BOOL "Build tests."
)

set (
QSERIALIZER_ENABLE_EXAMPLES ${PROJECT_IS_TOP_LEVEL}
CACHE BOOL "Build examples."
)

set (
QSERIALIZER_ENABLE_INSTALL ${PROJECT_IS_TOP_LEVEL}
CACHE BOOL "Enable the install target."
)
# cmake-format: on

set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)

set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTORCC ON)
set (CMAKE_AUTOUIC ON)

set (
QSERIALIZER_QT_VERSION_MAJOR
"6"
CACHE
STRING "The qt major version tests and examples link to."
)

find_package (
Qt${QSERIALIZER_QT_VERSION_MAJOR}
COMPONENTS
Expand Down Expand Up @@ -70,8 +85,26 @@ target_link_libraries (
QSerializer::Core Qt::DBus
)

if(QSERIALIZER_ENABLE_TESTING)
# Build tests
include (CTest)
include (GoogleTest)
enable_testing ()
find_package (GTest REQUIRED)
add_subdirectory (tests)
endif()

if(QSERIALIZER_ENABLE_EXAMPLES)
# Build examples
add_subdirectory (examples)
endif()

# Install

if(NOT QSERIALIZER_ENABLE_INSTALL)
return ()
endif()

include (GNUInstallDirs)

# cmake-format: off
Expand Down Expand Up @@ -128,25 +161,3 @@ install (
${CMAKE_INSTALL_LIBDIR}/cmake/QSerializer
)
# cmake-format: on

if(NOT PROJECT_IS_TOP_LEVEL)
return ()
endif()

# Build tests

option (
QSERIALIZER_ENABLE_TESTING "QSerializer: build tests."
${PROJECT_IS_TOP_LEVEL}
)
if(QSERIALIZER_ENABLE_TESTING)
include (CTest)
include (GoogleTest)
enable_testing ()
find_package (GTest REQUIRED)
add_subdirectory (tests)
endif()

# Build examples

add_subdirectory (examples)

0 comments on commit 1c4a600

Please sign in to comment.