Debian Codegraph @

plugins/core/Standard/qCork/cmake/CorkSupport.cmake

raw
1 # ------------------------------------------------------------------------------
2 # Quick & dirty Cork+MPIR+CMake support for CloudCompare
3 # ------------------------------------------------------------------------------
4
5 # Cork library (CC fork) https://github.com/cloudcompare/cork
6 set( CORK_INCLUDE_DIR "" CACHE PATH "Cork include directory" )
7 set( CORK_RELEASE_LIBRARY_FILE "" CACHE FILEPATH "Cork library file (release mode)" )
8 if (WIN32)
9 set( CORK_DEBUG_LIBRARY_FILE "" CACHE FILEPATH "Cork library file (debug mode)" )
10 endif()
11
12 if ( NOT CORK_INCLUDE_DIR )
13 message( SEND_ERROR "No Cork include dir specified (CORK_INCLUDE_DIR)" )
14 else()
15 target_include_directories( ${PROJECT_NAME}
16 PRIVATE
17 ${CORK_INCLUDE_DIR}
18 )
19 endif()
20
21 set( MPIR_INCLUDE_DIR "" CACHE PATH "MPIR include directory" )
22 set( MPIR_RELEASE_LIBRARY_FILE "" CACHE FILEPATH "MPIR library file (release mode)" )
23 if (WIN32)
24 set( MPIR_DEBUG_LIBRARY_FILE "" CACHE FILEPATH "MPIR library file (debug mode)" )
25 endif()
26
27 if ( NOT MPIR_INCLUDE_DIR )
28 message( SEND_ERROR "No MPIR include dir specified (MPIR_INCLUDE_DIR)" )
29 else()
30 target_include_directories( ${PROJECT_NAME}
31 PRIVATE
32 ${MPIR_INCLUDE_DIR}
33 )
34 endif()
35
36 # Link project with Cork + MPIR library
37 function( target_link_cork ) # 1 argument: ARGV0 = project name
38 if( CORK_RELEASE_LIBRARY_FILE AND MPIR_RELEASE_LIBRARY_FILE )
39 #Release mode only by default
40 target_link_libraries( ${ARGV0} optimized ${CORK_RELEASE_LIBRARY_FILE} ${MPIR_RELEASE_LIBRARY_FILE} )
41
42 #optional: debug mode
43 if ( CORK_DEBUG_LIBRARY_FILE AND MPIR_DEBUG_LIBRARY_FILE )
44 target_link_libraries( ${ARGV0} debug ${CORK_DEBUG_LIBRARY_FILE} ${MPIR_DEBUG_LIBRARY_FILE} )
45 endif()
46 else()
47 message( SEND_ERROR "No Cork or MPIR release library files specified (CORK_RELEASE_LIBRARY_FILE / MPIR_RELEASE_LIBRARY_FILE)" )
48 endif()
49 endfunction()