commit a88dc9ea88ea5db2abe6389e95261da130bafc90
parent e7fdf6095fb14e01d55bd99e2c7881a301cb0d27
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 31 Aug 2016 15:04:37 +0200
Add a Clipper CMake Module
Use the cross platform CMake package mechanism to find the clipper
library rather than using the PkgConfig CMake module that relies onto
the Unix specific pkg-config tool.
Diffstat:
2 files changed, 69 insertions(+), 20 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 2.8)
project(scpr C CXX)
enable_testing()
@@ -22,31 +22,18 @@ option(NO_TEST "Do not compile the test pograms" OFF)
set(SCPR_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src)
################################################################################
-# Setup the PkgConfig cmake module
-################################################################################
-set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
-
-# The PkgConfig CMake module does not support relative prefix paths. Ensure
-# that the provided prefix paths are absolute
-set(_cmake_prefix_path)
-foreach(_prefix ${CMAKE_PREFIX_PATH})
- get_filename_component(_prefix ${_prefix} ABSOLUTE)
- list(APPEND _cmake_prefix_path ${_prefix})
-endforeach()
-set(CMAKE_PREFIX_PATH ${_cmake_prefix_path})
-
-################################################################################
# Dependencies
################################################################################
+get_filename_component(_current_source_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
+set(Clipper_DIR ${_current_source_dir}/)
+
+find_package(Clipper REQUIRED)
find_package(RCMake REQUIRED)
find_package(RSys 0.4 REQUIRED)
find_package(Polygon 0.0.5 REQUIRED)
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(Clipper REQUIRED polyclipping)
-link_directories(${Clipper_LIBRARY_DIRS})
include_directories(
- ${Clipper_INCLUDE_DIRS}
+ ${Clipper_INCLUDE_DIR}
${Polygon_INCLUDE_DIR}
${RSys_INCLUDE_DIR})
@@ -77,7 +64,7 @@ set_target_properties(scpr PROPERTIES
DEFINE_SYMBOL SCPR_SHARED_BUILD
VERSION ${VERSION}
SOVERSION ${VERSION_MAJOR})
-target_link_libraries(scpr RSys Polygon ${Clipper_LIBRARIES})
+target_link_libraries(scpr RSys Polygon Clipper)
if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(scpr PROPERTIES COMPILE_FLAGS "-Wno-long-long")
diff --git a/cmake/ClipperConfig.cmake b/cmake/ClipperConfig.cmake
@@ -0,0 +1,62 @@
+# Copyright (C) |Meso|Star> 2016 (contact@meso-star.com)
+#
+# This software is a computer program whose purpose is to generate files
+# used to build the Star-3D library.
+#
+# This software is governed by the CeCILL license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/or redistribute the software under the terms of the CeCILL
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# "http://www.cecill.info".
+#
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+#
+# In this respect, the user's attention is drawn to the risks associated
+# with loading, using, modifying and/or developing or reproducing the
+# software by the user in light of its specific status of free software,
+# that may mean that it is complicated to manipulate, and that also
+# therefore means that it is reserved for developers and experienced
+# professionals having in-depth computer knowledge. Users are therefore
+# encouraged to load and test the software's suitability as regards their
+# requirements in conditions enabling the security of their systems and/or
+# data to be ensured and, more generally, to use and operate it in the
+# same conditions as regards security.
+#
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL license and that you accept its terms.
+
+cmake_minimum_required(VERSION 2.6)
+
+# Try to find the Clipper devel. Once done this will define:
+# - Clipper_FOUND: system has Clipper
+# - Clipper_INCLUDE_DIR: the include directory
+# - Clipper: Link this to use Clipper
+
+find_path(Clipper_INCLUDE_DIR polyclipping/clipper.hpp)
+set(Clipper_INCLUDE_DIR ${Clipper_INCLUDE_DIR}/polyclipping/)
+
+unset(Clipper_LIBRARY CACHE)
+unset(Clipper_LIBRARY_DEBUG CACHE)
+unset(Clipper_LIBRARY_RELWITHDEBINFO CACHE)
+unset(Clipper_LIBRARY_MINSIZEREL CACHE)
+find_library(Clipper_LIBRARY polyclipping DOC "Path to the clipper library.")
+
+# Create the imported library target
+if(CMAKE_HOST_WIN32)
+ set(_property IMPORTED_IMPLIB)
+else(CMAKE_HOST_WIN32)
+ set(_property IMPORTED_LOCATION)
+endif(CMAKE_HOST_WIN32)
+add_library(Clipper SHARED IMPORTED)
+set_target_properties(Clipper PROPERTIES ${_property} ${Clipper_LIBRARY})
+
+# Check the package
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Clipper DEFAULT_MSG
+ Clipper_INCLUDE_DIR
+ Clipper_LIBRARY)
+