[89] | 1 | #################################################
|
---|
| 2 | # ___________ ____ ______ __ __ _____ #
|
---|
| 3 | # \____ \__ \ _/ ___\\____ \| | \/ ___/ #
|
---|
| 4 | # | |_> > __ \\ \___| |_> > | /\___ \ #
|
---|
| 5 | # | __(____ /\___ > __/|____//____ > #
|
---|
| 6 | # |__| \/ \/|__| \/ #
|
---|
| 7 | # #
|
---|
| 8 | #################################################
|
---|
| 9 |
|
---|
| 10 | # TODO: write the output variables of this CMake file.
|
---|
| 11 |
|
---|
[304] | 12 | # Check PACPUS_ROOT
|
---|
| 13 | if(NOT PACPUS_ROOT)
|
---|
| 14 | if(NOT ENV{PACPUS_ROOT} STREQUAL "")
|
---|
| 15 | set(PACPUS_ROOT $ENV{PACPUS_ROOT})
|
---|
| 16 | string (REPLACE "\\" "/" PACPUS_ROOT ${PACPUS_ROOT})
|
---|
| 17 | message(STATUS "Detected PACPUS_ROOT in environment, set to '${PACPUS_ROOT}'")
|
---|
| 18 | else()
|
---|
| 19 | if(PACPUS_FIND_REQUIRED)
|
---|
| 20 | MESSAGE(FATAL_ERROR "Could'not find PACPUS_ROOT ")
|
---|
| 21 | else()
|
---|
| 22 | MESSAGE(STATUS "Could'not find PACPUS_ROOT ")
|
---|
| 23 | return()
|
---|
| 24 | endif()
|
---|
| 25 | endif()
|
---|
| 26 | else()
|
---|
| 27 | string (REPLACE "\\" "/" PACPUS_ROOT ${PACPUS_ROOT})
|
---|
| 28 | message(STATUS "Detected PACPUS_ROOT as argument with the path: '${PACPUS_ROOT}'")
|
---|
| 29 | endif()
|
---|
| 30 |
|
---|
| 31 |
|
---|
[129] | 32 | # Locate the include files
|
---|
| 33 | set(PACPUS_INCLUDE_HINTS
|
---|
| 34 | "${PACPUS_ROOT}/include"
|
---|
| 35 | "$ENV{PACPUS_ROOT}/include"
|
---|
| 36 | )
|
---|
| 37 | if(WIN32)
|
---|
| 38 | list(APPEND PACPUS_INCLUDE_HINTS
|
---|
| 39 | "C:/Program Files/Pacpus/include"
|
---|
| 40 | "C:/Program Files (x86)/Pacpus/include"
|
---|
| 41 | "C:/Pacpus/include"
|
---|
| 42 | "C:/lib/Pacpus/include"
|
---|
| 43 | "D:/Program Files/Pacpus/include"
|
---|
| 44 | "D:/Program Files (x86)/Pacpus/include"
|
---|
| 45 | "D:/Pacpus/include"
|
---|
| 46 | "D:/lib/Pacpus/include"
|
---|
| 47 | )
|
---|
| 48 | else()
|
---|
| 49 | # TODO: add default paths no Unix-like systems
|
---|
| 50 | list(APPEND PACPUS_INCLUDE_HINTS
|
---|
| 51 | )
|
---|
[89] | 52 | endif()
|
---|
[129] | 53 | find_path(PACPUS_INCLUDE_DIR
|
---|
| 54 | NAMES "Pacpus/kernel/pacpus.h"
|
---|
| 55 | HINTS ${PACPUS_INCLUDE_HINTS}
|
---|
| 56 | DOC "The Pacpus include directory"
|
---|
| 57 | )
|
---|
[89] | 58 |
|
---|
[129] | 59 | if(NOT PACPUS_INCLUDE_DIR)
|
---|
| 60 | message(FATAL_ERROR "Could not find PACPUS. Please set CMake variable PACPUS_ROOT or environment variable PACPUS_ROOT.")
|
---|
| 61 | endif()
|
---|
[89] | 62 |
|
---|
[304] | 63 |
|
---|
| 64 | #get_filename_component(PACPUS_ROOT ${PACPUS_INCLUDE_DIR}/.. ABSOLUTE)
|
---|
[129] | 65 | set(PACPUS_LIB_DIR ${PACPUS_ROOT}/lib)
|
---|
[89] | 66 |
|
---|
| 67 | # List of required modules
|
---|
| 68 | set(PACPUS_MODULES "FileLib" "PacpusLib" "PacpusTools" "dbiteplayerlib")
|
---|
| 69 | if(WIN32)
|
---|
| 70 | list(APPEND PACPUS_MODULES "ROAD_TIME")
|
---|
| 71 | endif()
|
---|
| 72 |
|
---|
| 73 | set(MODULE_MISSING FALSE)
|
---|
| 74 | set(PACPUS_LIBRARIES "")
|
---|
| 75 |
|
---|
[304] | 76 | message (${PACPUS_LIB_DIR})
|
---|
| 77 |
|
---|
[89] | 78 | # Check the presence of each module
|
---|
| 79 | foreach(module ${PACPUS_MODULES})
|
---|
[129] | 80 | # release version
|
---|
[89] | 81 | find_library(
|
---|
| 82 | PACPUS_${module}_LIB
|
---|
[129] | 83 | NAMES ${module}
|
---|
| 84 | HINTS ${PACPUS_LIB_DIR}
|
---|
[89] | 85 | )
|
---|
[129] | 86 | if(PACPUS_${module}_LIB AND PACPUS_${module}_LIBD)
|
---|
| 87 | list(APPEND PACPUS_LIBRARIES optimized ${PACPUS_${module}_LIB})
|
---|
| 88 | else()
|
---|
| 89 | message(SEND_ERROR "Cannot find Pacpus module ${module} (release version)")
|
---|
| 90 | set(MODULE_MISSING TRUE)
|
---|
| 91 | endif()
|
---|
| 92 |
|
---|
| 93 | # debug version
|
---|
[89] | 94 | find_library(
|
---|
| 95 | PACPUS_${module}_LIBD
|
---|
[129] | 96 | NAMES ${module}_d
|
---|
| 97 | HINTS ${PACPUS_LIB_DIR}
|
---|
[89] | 98 | )
|
---|
| 99 | if(PACPUS_${module}_LIB AND PACPUS_${module}_LIBD)
|
---|
| 100 | list(APPEND PACPUS_LIBRARIES debug ${PACPUS_${module}_LIBD})
|
---|
| 101 | else()
|
---|
[129] | 102 | message(SEND_ERROR "Cannot find Pacpus module ${module}_d (debug version)")
|
---|
[89] | 103 | set(MODULE_MISSING TRUE)
|
---|
| 104 | endif()
|
---|
| 105 | endforeach()
|
---|
| 106 |
|
---|
[129] | 107 | # handle the QUIETLY and REQUIRED arguments and set PACPUS_FOUND to TRUE if
|
---|
| 108 | # all listed variables are TRUE
|
---|
| 109 | include (FindPackageHandleStandardArgs)
|
---|
| 110 | set(PACPUS_ALL_MODULES_FOUND NOT MODULE_MISSING)
|
---|
| 111 | find_package_handle_standard_args (PACPUS DEFAULT_MSG PACPUS_LIBRARIES PACPUS_INCLUDE_DIR PACPUS_ALL_MODULES_FOUND)
|
---|
[89] | 112 |
|
---|
[129] | 113 | if(PACPUS_FOUND)
|
---|
[89] | 114 | set(PACPUS_INSTALL_DIR ${PACPUS_ROOT})
|
---|
[129] | 115 | set(PACPUS_CMAKE_DIR ${PACPUS_ROOT}/cmake)
|
---|
| 116 | set(CMAKE_INSTALL_PREFIX ${PACPUS_INSTALL_DIR})
|
---|
| 117 | list(APPEND CMAKE_PREFIX_PATH ${PACPUS_CMAKE_DIR})
|
---|
| 118 | list(APPEND CMAKE_MODULE_PATH "${PACPUS_CMAKE_DIR}")
|
---|
| 119 |
|
---|
| 120 | include(${PACPUS_CMAKE_DIR}/PacpusUtilities.cmake)
|
---|
| 121 | include(${PACPUS_CMAKE_DIR}/PacpusConfiguration.cmake)
|
---|
| 122 | include(${PACPUS_CMAKE_DIR}/PacpusDependencies.cmake)
|
---|
| 123 | include(${PACPUS_CMAKE_DIR}/PacpusPlatforms.cmake)
|
---|
[89] | 124 | endif()
|
---|