mirror of https://github.com/CGAL/cgal
modification for IPE
->move the version check and the installation directory detection into the demo CMakeLists.txt
This commit is contained in:
parent
3fde316a6c
commit
e7e15113ef
|
|
@ -7,26 +7,89 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
macro( remove_leading_zero var )
|
||||
string(SUBSTRING "${${var}}" 0 1 ONECHAR)
|
||||
string(COMPARE EQUAL "${ONECHAR}" "0" ISZERO)
|
||||
if (${ISZERO})
|
||||
string(SUBSTRING "${${var}}" 1 1 ONECHAR)
|
||||
set(${var} ${ONECHAR})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
|
||||
#path where to build libraries
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||
|
||||
find_package(CGAL QUIET COMPONENTS Core )
|
||||
set( IPE_VERSION "AUTODETECT" CACHE STRING "The version of Ipe. Only 6 and 7 are supported.")
|
||||
|
||||
find_package(CGAL QUIET COMPONENTS Core IPE)
|
||||
|
||||
if ( CGAL_FOUND )
|
||||
include( ${CGAL_USE_FILE} )
|
||||
find_package(IPE)
|
||||
if ( IPE_FOUND )
|
||||
include_directories(BEFORE ../../include)
|
||||
include_directories(include/CGAL_ipelets)
|
||||
include_directories(${IPE_INCLUDE_DIR})
|
||||
link_directories( ${IPE_LIBRARY_DIR} )
|
||||
|
||||
if ( IPE_FOUND )
|
||||
#check IPE version
|
||||
if (${IPE_VERSION} STREQUAL "AUTODETECT")
|
||||
FILE(READ "${IPE_INCLUDE_DIR}/ipebase.h" IPEBASE_H)
|
||||
STRING(REGEX MATCH "IPELIB_VERSION[ ]*=[ ]*([67])([0-9][0-9])([0-9][0-9]);" found_ipe_version "${IPEBASE_H}")
|
||||
if (found_ipe_version)
|
||||
set(IPE_VERSION ${CMAKE_MATCH_1})
|
||||
set(IPE_MINOR_VERSION_1 ${CMAKE_MATCH_2})
|
||||
set(IPE_MINOR_VERSION_2 ${CMAKE_MATCH_3})
|
||||
endif()
|
||||
endif()
|
||||
if (${IPE_VERSION} EQUAL "7")
|
||||
set(WITH_IPE_7 ON)
|
||||
elseif(${IPE_VERSION} EQUAL "6")
|
||||
set(WITH_IPE_7 OFF)
|
||||
else()
|
||||
message("-- Error: ${IPE_VERSION} is not a supported version of IPE (only 6 and 7 are).")
|
||||
set(IPE_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if ( IPE_FOUND )
|
||||
if (WITH_IPE_7)
|
||||
add_definitions(-DCGAL_USE_IPE_7)
|
||||
endif()
|
||||
|
||||
message("-- Using IPE version ${IPE_VERSION} compatibility.")
|
||||
|
||||
#setting installation directory
|
||||
get_filename_component(IPE_LIBRARY_DIR ${IPE_LIBRARIES} PATH)
|
||||
if (IPE_FOUND AND NOT IPELET_INSTALL_DIR)
|
||||
if (WITH_IPE_7)
|
||||
remove_leading_zero(IPE_MINOR_VERSION_1)
|
||||
remove_leading_zero(IPE_MINOR_VERSION_2)
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} "${IPE_LIBRARY_DIR}/ipe/7.${IPE_MINOR_VERSION_1}.${IPE_MINOR_VERSION_2}/ipelets/")
|
||||
find_path(IPELET_INSTALL_DIR
|
||||
NAMES libgoodies.lua goodies.lua
|
||||
PATHS ${INSTALL_PATHS}
|
||||
ENV IPELETPATH
|
||||
)
|
||||
else()
|
||||
foreach (VER RANGE 28 40)
|
||||
string(REPLACE XX ${VER} PATHC "${IPE_LIBRARY_DIR}/ipe/6.0preXX/ipelets/" )
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} ${PATHC})
|
||||
endforeach()
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} ${PATHC})
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} /usr/lib64/ipe/6.0/ipelets)
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} /usr/lib/ipe/6.0/ipelets)
|
||||
|
||||
|
||||
find_library(IPELET_INSTALL_DIR_FILES
|
||||
NAMES align
|
||||
PATHS ${INSTALL_PATHS}
|
||||
ENV IPELETPATH
|
||||
)
|
||||
if (IPELET_INSTALL_DIR_FILES)
|
||||
get_filename_component(IPELET_INSTALL_DIR ${IPELET_INSTALL_DIR_FILES} PATH)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CGAL_IPELETS ${CGAL_IPELETS})
|
||||
set(CGAL_IPELETS ${CGAL_IPELETS} alpha_shapes)
|
||||
set(CGAL_IPELETS ${CGAL_IPELETS} arrangement)
|
||||
|
|
@ -44,11 +107,9 @@ if ( CGAL_FOUND )
|
|||
set(CGAL_IPELETS ${CGAL_IPELETS} skeleton)
|
||||
set(CGAL_IPELETS ${CGAL_IPELETS} triangulation)
|
||||
|
||||
|
||||
foreach(IPELET ${CGAL_IPELETS})
|
||||
add_library(CGAL_${IPELET} MODULE ${IPELET}.cpp)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGAL_${IPELET})
|
||||
target_link_libraries( CGAL_${IPELET} ipe)
|
||||
if ( IPELET_INSTALL_DIR )
|
||||
install(TARGETS CGAL_${IPELET} DESTINATION ${IPELET_INSTALL_DIR})
|
||||
if (WITH_IPE_7)
|
||||
|
|
@ -58,7 +119,6 @@ if ( CGAL_FOUND )
|
|||
endforeach(IPELET)
|
||||
#example in doc not installed
|
||||
add_library(simple_triangulation MODULE simple_triangulation.cpp)
|
||||
target_link_libraries( simple_triangulation ipe )
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS simple_triangulation)
|
||||
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ the demo directory of this package. To install them you need
|
|||
to go to the demo directory of the package and run cmake.
|
||||
The compilation of these demo requires the source tree and the library of Ipe.
|
||||
If your Ipe installation is not detected you need to set the cmake
|
||||
variables \ccc{IPE_INCLUDE_DIR} and \ccc{IPE_LIBRARY_DIR}. If you want
|
||||
variables \ccc{IPE_INCLUDE_DIR} and \ccc{IPE_LIBRARIES}. If you want
|
||||
to install ipelets automatically (using \ccc{make install} for example)
|
||||
you also need to set the cmake variable \ccc{IPELET_INSTALL_DIR},
|
||||
if the ipelet installation path has not already been detected.
|
||||
|
|
|
|||
|
|
@ -8,17 +8,8 @@
|
|||
#
|
||||
|
||||
|
||||
macro( remove_leading_zero var )
|
||||
string(SUBSTRING "${${var}}" 0 1 ONECHAR)
|
||||
string(COMPARE EQUAL "${ONECHAR}" "0" ISZERO)
|
||||
if (${ISZERO})
|
||||
string(SUBSTRING "${${var}}" 1 1 ONECHAR)
|
||||
set(${var} ${ONECHAR})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Is it already configured?
|
||||
if (IPE_INCLUDE_DIR AND IPE_LIBRARY_DIR )
|
||||
if (IPE_INCLUDE_DIR AND IPE_LIBRARIES )
|
||||
set(IPE_FOUND TRUE)
|
||||
else()
|
||||
|
||||
|
|
@ -28,73 +19,20 @@ else()
|
|||
/usr/local/include
|
||||
)
|
||||
|
||||
find_library(IPE_LIBRARY
|
||||
find_library(IPE_LIBRARIES
|
||||
NAMES ipe
|
||||
PATHS /usr/lib
|
||||
/usr/local/lib
|
||||
/usr/lib64
|
||||
)
|
||||
|
||||
if(IPE_INCLUDE_DIR AND IPE_LIBRARY)
|
||||
if(IPE_INCLUDE_DIR AND IPE_LIBRARIES)
|
||||
set(IPE_FOUND TRUE)
|
||||
if (NOT IPE_VERSION)
|
||||
set(IPE_VERSION "AUTODETECT")
|
||||
endif()
|
||||
if (${IPE_VERSION} STREQUAL "AUTODETECT")
|
||||
FILE(READ "${IPE_INCLUDE_DIR}/ipebase.h" IPEBASE_H)
|
||||
STRING(REGEX MATCH "IPELIB_VERSION[ ]*=[ ]*([67])([0-9][0-9])([0-9][0-9]);" found_ipe_version "${IPEBASE_H}")
|
||||
if (found_ipe_version)
|
||||
set(IPE_VERSION ${CMAKE_MATCH_1})
|
||||
set(IPE_MINOR_VERSION_1 ${CMAKE_MATCH_2})
|
||||
set(IPE_MINOR_VERSION_2 ${CMAKE_MATCH_3})
|
||||
endif()
|
||||
endif()
|
||||
if (${IPE_VERSION} EQUAL "7")
|
||||
set(WITH_IPE_7 ON)
|
||||
elseif(${IPE_VERSION} EQUAL "6")
|
||||
set(WITH_IPE_7 OFF)
|
||||
else()
|
||||
message("-- Error: ${IPE_VERSION} is not a supported version of IPE (only 6 and 7 are).")
|
||||
set(IPE_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
get_filename_component(IPE_LIBRARY_DIR ${IPE_LIBRARY} PATH)
|
||||
endif()
|
||||
|
||||
if (IPE_FOUND AND NOT IPELET_INSTALL_DIR)
|
||||
message("-- Using IPE version ${IPE_VERSION} compatibility.")
|
||||
if (WITH_IPE_7)
|
||||
remove_leading_zero(IPE_MINOR_VERSION_1)
|
||||
remove_leading_zero(IPE_MINOR_VERSION_2)
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} "${IPE_LIBRARY_DIR}/ipe/7.${IPE_MINOR_VERSION_1}.${IPE_MINOR_VERSION_2}/ipelets/")
|
||||
find_path(IPELET_INSTALL_DIR
|
||||
NAMES libgoodies.lua goodies.lua
|
||||
PATHS ${INSTALL_PATHS}
|
||||
ENV IPELETPATH
|
||||
)
|
||||
else()
|
||||
foreach (VER RANGE 28 40)
|
||||
string(REPLACE XX ${VER} PATHC "${IPE_LIBRARY_DIR}/ipe/6.0preXX/ipelets/" )
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} ${PATHC})
|
||||
endforeach()
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} ${PATHC})
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} /usr/lib64/ipe/6.0/ipelets)
|
||||
set(INSTALL_PATHS ${INSTALL_PATHS} /usr/lib/ipe/6.0/ipelets)
|
||||
|
||||
|
||||
find_library(IPELET_INSTALL_DIR_FILES
|
||||
NAMES align
|
||||
PATHS ${INSTALL_PATHS}
|
||||
ENV IPELETPATH
|
||||
)
|
||||
if (IPELET_INSTALL_DIR_FILES)
|
||||
get_filename_component(IPELET_INSTALL_DIR ${IPELET_INSTALL_DIR_FILES} PATH)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(IPE_FOUND)
|
||||
message(STATUS "Found Ipe: ${IPE_INCLUDE_DIR} ${IPE_LIBRARY_DIR}")
|
||||
message(STATUS "Found Ipe: ${IPE_INCLUDE_DIR} ${IPE_LIBRARIES}")
|
||||
if (IPELET_INSTALL_DIR)
|
||||
set ( IPELET_INSTALL_DIR ${IPELET_INSTALL_DIR} CACHE STRING "The folder where ipelets will be installed, relative to CMAKE_INSTALL_PREFIX" )
|
||||
message(STATUS "Set Ipelets install dir: ${IPELET_INSTALL_DIR}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue