Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ project(serial_cpp VERSION ${SERIAL_CPP_MAJOR_VERSION}.${SERIAL_CPP_MINOR_VERSIO
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" OFF)
option(BUILD_TESTING "Build tests" OFF)
option(serial_cpp_INSTALL "Enable generation of serial_cpp install targets" ON)
mark_as_advanced(serial_cpp_INSTALL)
option(serial_cpp_FORCE_RESPECT_BUILD_TESTING "If also BUILD_TESTING is ON, enable tests even if project was included via add_subdirectory/FetchContent" OFF)
mark_as_advanced(serial_cpp_FORCE_RESPECT_BUILD_TESTING)

# Detect if project is top level or not (fall back for CMake < 3.21)
if(CMAKE_VERSION VERSION_LESS "3.21.0")
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(PROJECT_IS_TOP_LEVEL ON)
else()
set(PROJECT_IS_TOP_LEVEL OFF)
endif()
endif()


# Default install locations
include(GNUInstallDirs)
Expand Down Expand Up @@ -120,6 +133,10 @@ endif()

## Tests
include(CTest)
if(BUILD_TESTING)
# Tests are enabled if BUILD_TESTING is enabled and PROJECT_IS_TOP_LEVEL is ON,
# or if serial_cpp_FORCE_RESPECT_BUILD_TESTING is ON, so if you include the project
# via FetchContent or add_subdirectory and if you want to compile tests, you
# need to set both BUILD_TESTING and serial_cpp_FORCE_RESPECT_BUILD_TESTING to ON
if(BUILD_TESTING OR (PROJECT_IS_TOP_LEVEL OR serial_cpp_FORCE_RESPECT_BUILD_TESTING))
add_subdirectory(tests)
endif()
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package>
<name>serial_cpp</name>
<version>1.3.1</version>
<version>1.3.2</version>
<description>
serial_cpp is a cross-platform, simple to use library for using serial ports on computers.
This library provides a C++, object oriented interface for interacting with RS-232
Expand Down