Skip to content

Commit

Permalink
Fix cmake trouble in cross compilation environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Haefner committed Aug 19, 2021
1 parent 54cb18e commit 24eeb7d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ project(simppl VERSION 0.3.0)
if(PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(SIMPPL_NOT_SUBPROJECT ON)

include(CTest)
endif()

# Reference the FindDBus module until an upstream one is available
Expand All @@ -24,13 +22,19 @@ endif()
# enable introspection by default
option(HAVE_INTROSPECTION "Have introspection" ON)
include(CMakeDependentOption)

cmake_dependent_option(SIMPPL_BUILD_TESTS "Build tests"
ON "SIMPPL_NOT_SUBPROJECT" OFF
)

cmake_dependent_option(SIMPPL_BUILD_EXAMPLES "Build examples"
ON "SIMPPL_NOT_SUBPROJECT" OFF
)

if(SIMPPL_BUILD_TESTS)
include(CTest)
endif()

# enable threading
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
Expand All @@ -39,6 +43,7 @@ find_package(Threads REQUIRED)
find_package(DBus REQUIRED)
find_package(Boost)


add_library(simppl SHARED
src/dispatcher.cpp
src/error.cpp
Expand Down Expand Up @@ -82,7 +87,9 @@ target_link_libraries(simppl PUBLIC
)

# Build a set of examples
add_subdirectory(examples)
if(SIMPPL_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

if(SIMPPL_BUILD_TESTS AND BUILD_TESTING)
add_subdirectory(tests)
Expand All @@ -107,6 +114,9 @@ if(SIMPPL_NOT_SUBPROJECT)
NAMESPACE Simppl::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/simppl
)
install(DIRECTORY include/simppl
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

configure_package_config_file(cmake/SimpplConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SimpplConfig.cmake
Expand Down

0 comments on commit 24eeb7d

Please sign in to comment.