From 7b036891787ba2a3fadb3e77a3bb315574bc5d9f Mon Sep 17 00:00:00 2001 From: spo Date: Fri, 11 Sep 2015 14:43:04 +0300 Subject: [PATCH] Issue #830 - cmake must fail if SolveSpace has not been found --- CMakeCommon/FindSolveSpace.cmake | 35 ++++++++++++++++++++++++++++---- CMakeLists.txt | 2 -- make.sh | 2 ++ src/SketchSolver/CMakeLists.txt | 5 +++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/CMakeCommon/FindSolveSpace.cmake b/CMakeCommon/FindSolveSpace.cmake index 40acbbe8c..2830c7bba 100644 --- a/CMakeCommon/FindSolveSpace.cmake +++ b/CMakeCommon/FindSolveSpace.cmake @@ -1,8 +1,35 @@ +# - Try to find SolveSpace +# Once done this will define +# +# SolveSpace_FOUND - system has SolveSpace +# SolveSpace_INCLUDE_DIRS - the SolveSpace include directory +# SolveSpace_LIBRARIES - Link these to use SolveSpace + +#============================================================================= ## Copyright (C) 2014-20xx CEA/DEN, EDF R&D +#============================================================================= + +SET(_SolveSpace_PATHS $ENV{SOLVESPACE_ROOT_DIR}) + +FIND_PATH(SolveSpace_INCLUDE_DIR NAMES slvs.h + PATHS ${_SolveSpace_PATHS} + PATH_SUFFIXES include) + +FIND_LIBRARY(SolveSpace_LIBRARY NAMES slvs + PATHS ${_SolveSpace_PATHS} + PATH_SUFFIXES lib) + +SET(SolveSpace_INCLUDE_DIRS ${SolveSpace_INCLUDE_DIR}) +SET(SolveSpace_LIBRARIES ${SolveSpace_LIBRARY}) -SET(SLVS_ROOT_DIR $ENV{SOLVESPACE_ROOT_DIR}) +INCLUDE(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set SolveSpace_FOUND to TRUE +# if all listed variables are TRUE +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SolveSpace DEFAULT_MSG + SolveSpace_LIBRARY SolveSpace_INCLUDE_DIR) -INCLUDE_DIRECTORIES(${SLVS_ROOT_DIR}/include) -LINK_DIRECTORIES(${SLVS_ROOT_DIR}/lib) +MARK_AS_ADVANCED(SolveSpace_LIBRARY SolveSpace_INCLUDE_DIR) -SET(SLVS_LIBRARIES slvs) +IF(NOT SolveSpace_FIND_QUIET) + MESSAGE(STATUS "SolveSpace found at ${_SolveSpace_PATHS}") +ENDIF() \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ac46e691..270275754 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,9 @@ INCLUDE(Common) INCLUDE(FindQt) INCLUDE(FindPython) INCLUDE(FindSalome) -INCLUDE(FindSolveSpace) INCLUDE(FindCAS) INCLUDE(FindSUIT) - IF(UNIX) IF(CMAKE_COMPILER_IS_GNUCC) #C++11 is not supported on some platforms, disable it diff --git a/make.sh b/make.sh index 2b19c4102..5c8227185 100755 --- a/make.sh +++ b/make.sh @@ -20,5 +20,7 @@ CMAKE_ARGS="${CMAKE_ARGS} ${SOURCES_DIR}" mkdir -p ${BUILD_DIR} cd ${BUILD_DIR} +set -e + cmake -G "Unix Makefiles" ${CMAKE_ARGS} make -j$(nproc) install diff --git a/src/SketchSolver/CMakeLists.txt b/src/SketchSolver/CMakeLists.txt index 7c4c8c29e..a625eeaf1 100644 --- a/src/SketchSolver/CMakeLists.txt +++ b/src/SketchSolver/CMakeLists.txt @@ -1,7 +1,7 @@ ## Copyright (C) 2014-20xx CEA/DEN, EDF R&D INCLUDE(Common) -INCLUDE(FindSolveSpace) +FIND_PACKAGE(SolveSpace REQUIRED) SET(PROJECT_HEADERS SketchSolver.h @@ -52,7 +52,7 @@ SET(PROJECT_SOURCES ) SET(PROJECT_LIBRARIES - ${SLVS_LIBRARIES} + ${SolveSpace_LIBRARIES} Config Events ModelAPI @@ -60,6 +60,7 @@ SET(PROJECT_LIBRARIES ) INCLUDE_DIRECTORIES( + ${SolveSpace_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/Config ${PROJECT_SOURCE_DIR}/src/SketchPlugin ${PROJECT_SOURCE_DIR}/src/ModelAPI -- 2.39.2