Skip to content

Commit

Permalink
Add check for cereal library in CMake
Browse files Browse the repository at this point in the history
Fixes prusa3d#3547, replaces prusa3d#3613
  • Loading branch information
tamasmeszaros committed Feb 7, 2020
1 parent a1c0a29 commit 2fb1acd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ if (NOT GLEW_FOUND)
endif ()

# Find the Cereal serialization library
add_library(cereal INTERFACE)
target_include_directories(cereal INTERFACE include)
find_package(cereal REQUIRED)

# l10n
set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization")
Expand Down
26 changes: 26 additions & 0 deletions cmake/modules/Findcereal.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
set(_q "")
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(_q QUIET)
set(_quietly TRUE)
endif()
find_package(${CMAKE_FIND_PACKAGE_NAME} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION} CONFIG ${_q})

if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND)
# Fall-back solution to find the Cereal serialization library header file
include(CheckIncludeFileCXX)
add_library(cereal INTERFACE)
target_include_directories(cereal INTERFACE include)

if (_quietly)
set(CMAKE_REQUIRED_QUIET ON)
endif()
CHECK_INCLUDE_FILE_CXX("cereal/cereal.hpp" HAVE_CEREAL_H)

if (NOT HAVE_CEREAL_H)
if (${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
message(FATAL_ERROR "Cereal library not found. Please install the dependency.")
elseif(NOT _quietly)
message(WARNING "Cereal library not found.")
endif()
endif ()
endif()

0 comments on commit 2fb1acd

Please sign in to comment.