I had a problem with building Clipper 6.4.2 using CMake where I’d get the following configuration error:
CMake Error at CMakeLists.txt:18 (INSTALL): install TARGETS given no ARCHIVE DESTINATION for static library target "polyclipping".
This was irrespective of whether I chose to build a shared library (.dll/.so) or a static one (.lib/.a).
The CMakeLists.txt file that comes with version 6.4.2 looks as follows:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
PROJECT(polyclipping)
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Release type")
# The header name clipper.hpp is too generic, so install in a subdirectory
SET(CMAKE_INSTALL_INCDIR "${CMAKE_INSTALL_PREFIX}/include/polyclipping")
SET(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
SET(CMAKE_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig")
SET(PCFILE "${CMAKE_CURRENT_BINARY_DIR}/polyclipping.pc")
SET(BUILD_SHARED_LIBS ON CACHE BOOL
"Build shared libraries (.dll/.so) instead of static ones (.lib/.a)")
ADD_LIBRARY(polyclipping clipper.cpp)
CONFIGURE_FILE (polyclipping.pc.cmakein "${PCFILE}" @ONLY)
INSTALL (FILES clipper.hpp DESTINATION "${CMAKE_INSTALL_INCDIR}")
INSTALL (TARGETS polyclipping LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
INSTALL (FILES "${PCFILE}" DESTINATION "${CMAKE_INSTALL_PKGCONFIGDIR}")
SET_TARGET_PROPERTIES(polyclipping PROPERTIES VERSION 22.0.0 SOVERSION 22 )
The offending line is emphasized in bold. This is insufficient according to this StackOverflow post.
I edited the line as follows:
INSTALL (TARGETS polyclipping
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
And configuration succeeded.