Remove dependency on pkg-config (#398)

Considering that on FreeBSD, pkg-config has been replaced by pkgconfig, we should remove the dependency on pkg-config.
This commit is contained in:
An Tao 2020-03-21 12:41:15 +08:00 committed by GitHub
parent 98ab826cfc
commit f5e87acd9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 116 additions and 27 deletions

View File

@ -28,8 +28,8 @@ set(INSTALL_DROGON_CMAKE_DIR
if(BUILD_DROGON_SHARED)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}"
isSystemDir)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}")
endif("${isSystemDir}" STREQUAL "-1")
@ -62,12 +62,6 @@ if(WIN32)
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/mman-win32>)
endif(WIN32)
# set the include list for dynamic view compiling
# list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW
# ${PROJECT_SOURCE_DIR}/lib/inc
# ${PROJECT_SOURCE_DIR}/orm_lib/inc
# ${PROJECT_SOURCE_DIR}/trantor)
add_subdirectory(trantor)
target_link_libraries(${PROJECT_NAME} PUBLIC trantor)
@ -98,14 +92,14 @@ list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW ${JSONCPP_INCLUDE_DIRS})
if(NOT WIN32)
find_package(UUID REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::libuuid)
target_link_libraries(${PROJECT_NAME} PRIVATE UUID_lib)
try_compile(normal_uuid ${CMAKE_BINARY_DIR}/cmaketest
${PROJECT_SOURCE_DIR}/cmake/tests/normal_uuid_lib_test.cc
LINK_LIBRARIES PkgConfig::libuuid)
LINK_LIBRARIES UUID_lib)
try_compile(ossp_uuid ${CMAKE_BINARY_DIR}/cmaketest
${PROJECT_SOURCE_DIR}/cmake/tests/ossp_uuid_lib_test.cc
LINK_LIBRARIES PkgConfig::libuuid)
LINK_LIBRARIES UUID_lib)
if(normal_uuid)
add_definitions(-DUSE_OSSP_UUID=0)
elseif(ossp_uuid)
@ -299,7 +293,8 @@ else(CMAKE_BUILD_TYPE)
set(COMPILATION_FLAGS "-std=c++")
endif(CMAKE_BUILD_TYPE)
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
list(APPEND INCLUDE_DIRS_FOR_DYNAMIC_VIEW
"${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
list(REMOVE_DUPLICATES INCLUDE_DIRS_FOR_DYNAMIC_VIEW)
set(INS_STRING "")
foreach(loop_var ${INCLUDE_DIRS_FOR_DYNAMIC_VIEW})

View File

@ -1,24 +1,118 @@
# - Try to find UUID
# Once done this will define
# * Try to find UUID Once done this will define
#
# UUID_FOUND - system has UUID
# UUID_FOUND - system has UUID
# UUID_INCLUDE_DIRS - the UUID include directory
# UUID_LIBRARIES - Link these to use UUID
# UUID_DEFINITIONS - Compiler switches required for using UUID
# UUID_LIBRARIES - Link these to use UUID UUID_DEFINITIONS - Compiler switches
# required for using UUID
#
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# Redistribution and use is allowed according to the terms of the New BSD
# license. For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
find_package(PkgConfig REQUIRED)
if(UUID_LIBRARIES AND UUID_INCLUDE_DIRS)
# in cache already
set(UUID_FOUND TRUE)
else(UUID_LIBRARIES AND UUID_INCLUDE_DIRS)
find_path(
UUID_INCLUDE_DIR
NAMES uuid.h
PATH_SUFFIXES uuid
HINTS ${UUID_DIR}/include
$ENV{UUID_DIR}/include
$ENV{UUID_DIR}
${DELTA3D_EXT_DIR}/inc
$ENV{DELTA_ROOT}/ext/inc
$ENV{DELTA_ROOT}
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/usr/include/gdal
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
/usr/freeware/include)
pkg_check_modules(libuuid
REQUIRED
IMPORTED_TARGET
uuid
)
find_library(UUID_LIBRARY
NAMES uuid ossp-uuid
HINTS ${UUID_DIR}/lib
$ENV{UUID_DIR}/lib
$ENV{UUID_DIR}
${DELTA3D_EXT_DIR}/lib
$ENV{DELTA_ROOT}/ext/lib
$ENV{DELTA_ROOT}
$ENV{OSG_ROOT}/lib
PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64)
set(UUID_FOUND TRUE)
find_library(UUID_LIBRARY_DEBUG
NAMES uuidd
HINTS ${UUID_DIR}/lib
$ENV{UUID_DIR}/lib
$ENV{UUID_DIR}
${DELTA3D_EXT_DIR}/lib
$ENV{DELTA_ROOT}/ext/lib
$ENV{DELTA_ROOT}
$ENV{OSG_ROOT}/lib
PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64)
if(NOT UUID_LIBRARY AND BSD)
set(UUID_LIBRARY "")
endif(NOT UUID_LIBRARY AND BSD)
set(UUID_INCLUDE_DIRS ${UUID_INCLUDE_DIR})
set(UUID_LIBRARIES ${UUID_LIBRARY})
if(UUID_INCLUDE_DIRS)
if(BSD OR UUID_LIBRARIES)
set(UUID_FOUND TRUE)
endif(BSD OR UUID_LIBRARIES)
endif(UUID_INCLUDE_DIRS)
if(UUID_FOUND)
if(NOT UUID_FIND_QUIETLY)
message(STATUS "Found UUID: ${UUID_LIBRARIES}")
endif(NOT UUID_FIND_QUIETLY)
else(UUID_FOUND)
if(UUID_FIND_REQUIRED)
message(FATAL_ERROR "Could not find UUID")
endif(UUID_FIND_REQUIRED)
endif(UUID_FOUND)
# show the UUID_INCLUDE_DIRS and UUID_LIBRARIES variables only in the advanced
# view
mark_as_advanced(UUID_INCLUDE_DIRS UUID_LIBRARIES)
endif(UUID_LIBRARIES AND UUID_INCLUDE_DIRS)
if(UUID_FOUND)
add_library(UUID_lib INTERFACE IMPORTED)
set_target_properties(UUID_lib
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${UUID_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES
"${UUID_LIBRARIES}")
else(UUID_FOUND)
set(UUID_LIBRARIES)
set(UUID_INCLUDE_DIRS)
endif(UUID_FOUND)