Skip to content

Commit 2a18b4c

Browse files
committed
CDRIVER-1349 let CMake calculate package config directories
1 parent 4597ae8 commit 2a18b4c

File tree

6 files changed

+18
-58
lines changed

6 files changed

+18
-58
lines changed

build/cmake/MongoCPackage.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
set (PACKAGE_INCLUDE_INSTALL_DIRS ${MONGOC_HEADER_INSTALL_DIR})
2-
set (PACKAGE_LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR})
1+
set (INCLUDE_INSTALL_DIRS ${MONGOC_HEADER_INSTALL_DIR})
2+
set (LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR})
33
set (PACKAGE_LIBRARIES mongoc-1.0)
44

55
include (CMakePackageConfigHelpers)
@@ -11,7 +11,7 @@ function (install_package_config_file prefix)
1111
build/cmake/libmongoc-${prefix}-${suffix}.in
1212
${CMAKE_CURRENT_BINARY_DIR}/libmongoc-${prefix}-${suffix}
1313
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libmongoc-${prefix}
14-
PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS
14+
PATH_VARS INCLUDE_INSTALL_DIRS LIBRARY_INSTALL_DIRS
1515
)
1616

1717
install (

build/cmake/libmongoc-1.0-config.cmake.in

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,16 @@ set (MONGOC_VERSION @MONGOC_VERSION@)
1919

2020
find_package (libbson-1.0 "@MONGOC_MAJOR_VERSION@.@MONGOC_MINOR_VERSION@" REQUIRED)
2121

22-
# In a pure-CMake project this is inserted by configure_package_config_file (),
23-
# but we want to be able to build this file the same from the Autotools, so
24-
# let's manually insert this code.
25-
get_filename_component (PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
22+
@PACKAGE_INIT@
2623

27-
macro (set_and_check _var _file)
28-
set (${_var} "${_file}")
29-
if (NOT EXISTS "${_file}")
30-
message (FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
31-
endif ()
32-
endmacro ()
33-
34-
set_and_check (MONGOC_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/libmongoc-1.0")
24+
set_and_check (MONGOC_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIRS@")
3525
list (APPEND MONGOC_INCLUDE_DIRS ${BSON_INCLUDE_DIRS})
3626

3727
# We want to provide an absolute path to the library and we know the
3828
# directory and the base name, but not the suffix, so we use CMake's
3929
# find_library () to pick that up. Users can override this by configuring
4030
# MONGOC_LIBRARY themselves.
41-
find_library (MONGOC_LIBRARY mongoc-1.0 PATHS "${PACKAGE_PREFIX_DIR}/lib" NO_DEFAULT_PATH)
31+
find_library (MONGOC_LIBRARY mongoc-1.0 PATHS "@PACKAGE_LIBRARY_INSTALL_DIRS@" NO_DEFAULT_PATH)
4232
set (MONGOC_LIBRARIES ${MONGOC_LIBRARY} ${BSON_LIBRARIES})
4333

4434
# If this file is generated by the Autotools on Mac, SSL_LIBRARIES might be

build/cmake/libmongoc-static-1.0-config.cmake.in

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,16 @@ set (MONGOC_STATIC_VERSION @MONGOC_VERSION@)
1919

2020
find_package (libbson-static-1.0 "@MONGOC_MAJOR_VERSION@.@MONGOC_MINOR_VERSION@" REQUIRED)
2121

22-
# In a pure-CMake project this is inserted by configure_package_config_file (),
23-
# but we want to be able to build this file the same from the Autotools, so
24-
# let's manually insert this code.
25-
get_filename_component (PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
22+
@PACKAGE_INIT@
2623

27-
macro (set_and_check _var _file)
28-
set (${_var} "${_file}")
29-
if (NOT EXISTS "${_file}")
30-
message (FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
31-
endif ()
32-
endmacro ()
33-
34-
set_and_check (MONGOC_STATIC_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/libmongoc-1.0")
24+
set_and_check (MONGOC_STATIC_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIRS@")
3525
list (APPEND MONGOC_STATIC_INCLUDE_DIRS ${BSON_STATIC_INCLUDE_DIRS})
3626

3727
# We want to provide an absolute path to the library and we know the
3828
# directory and the base name, but not the suffix, so we use CMake's
3929
# find_library () to pick that up. Users can override this by configuring
4030
# MONGOC_STATIC_LIBRARY themselves.
41-
find_library (MONGOC_STATIC_LIBRARY mongoc-static-1.0 PATHS "${PACKAGE_PREFIX_DIR}/lib" NO_DEFAULT_PATH)
31+
find_library (MONGOC_STATIC_LIBRARY mongoc-static-1.0 PATHS "@PACKAGE_LIBRARY_INSTALL_DIRS@" NO_DEFAULT_PATH)
4232
if (MSVC)
4333
set (MONGOC_STATIC_LIB_EXT "lib")
4434
else ()

src/libbson/build/cmake/BSONPackage.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
set (PACKAGE_INCLUDE_INSTALL_DIRS ${BSON_HEADER_INSTALL_DIR})
2-
set (PACKAGE_LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR})
1+
set (INCLUDE_INSTALL_DIRS ${BSON_HEADER_INSTALL_DIR})
2+
set (LIBRARY_INSTALL_DIRS ${CMAKE_INSTALL_LIBDIR})
33
set (PACKAGE_LIBRARIES bson-1.0)
44

55
include (CMakePackageConfigHelpers)
@@ -11,7 +11,7 @@ function (install_package_config_file prefix)
1111
build/cmake/libbson-${prefix}-${suffix}.in
1212
${CMAKE_CURRENT_BINARY_DIR}/libbson-${prefix}-${suffix}
1313
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libbson-${prefix}
14-
PATH_VARS PACKAGE_INCLUDE_INSTALL_DIRS PACKAGE_LIBRARY_INSTALL_DIRS
14+
PATH_VARS INCLUDE_INSTALL_DIRS LIBRARY_INSTALL_DIRS
1515
)
1616

1717
install (

src/libbson/build/cmake/libbson-1.0-config.cmake.in

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,15 @@ set (BSON_MINOR_VERSION @BSON_MINOR_VERSION@)
1717
set (BSON_MICRO_VERSION @BSON_MICRO_VERSION@)
1818
set (BSON_VERSION @BSON_VERSION@)
1919

20-
# In a pure-CMake project this is inserted by configure_package_config_file (),
21-
# but we want to be able to build this file the same from the Autotools, so
22-
# let's manually insert this code.
23-
get_filename_component (PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
20+
@PACKAGE_INIT@
2421

25-
macro (set_and_check _var _file)
26-
set (${_var} "${_file}")
27-
if (NOT EXISTS "${_file}")
28-
message (FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
29-
endif ()
30-
endmacro ()
31-
32-
set_and_check (BSON_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/libbson-1.0")
22+
set_and_check (BSON_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIRS@")
3323

3424
# We want to provide an absolute path to the library and we know the
3525
# directory and the base name, but not the suffix, so we use CMake's
3626
# find_library () to pick that up. Users can override this by configuring
3727
# BSON_LIBRARY themselves.
38-
find_library (BSON_LIBRARY bson-1.0 PATHS "${PACKAGE_PREFIX_DIR}/lib" NO_DEFAULT_PATH)
28+
find_library (BSON_LIBRARY bson-1.0 PATHS "@PACKAGE_LIBRARY_INSTALL_DIRS@" NO_DEFAULT_PATH)
3929

4030
set (BSON_LIBRARIES ${BSON_LIBRARY})
4131

src/libbson/build/cmake/libbson-static-1.0-config.cmake.in

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,15 @@ set (BSON_STATIC_MINOR_VERSION @BSON_MINOR_VERSION@)
1717
set (BSON_STATIC_MICRO_VERSION @BSON_MICRO_VERSION@)
1818
set (BSON_STATIC_VERSION @BSON_VERSION@)
1919

20-
# In a pure-CMake project this is inserted by configure_package_config_file (),
21-
# but we want to be able to build this file the same from the Autotools, so
22-
# let's manually insert this code.
23-
get_filename_component (PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
20+
@PACKAGE_INIT@
2421

25-
macro (set_and_check _var _file)
26-
set (${_var} "${_file}")
27-
if (NOT EXISTS "${_file}")
28-
message (FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
29-
endif ()
30-
endmacro ()
31-
32-
set_and_check (BSON_STATIC_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/libbson-1.0")
22+
set_and_check (BSON_STATIC_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIRS@")
3323

3424
# We want to provide an absolute path to the library and we know the
3525
# directory and the base name, but not the suffix, so we use CMake's
3626
# find_library () to pick that up. Users can override this by configuring
3727
# BSON_STATIC_LIBRARY themselves.
38-
find_library (BSON_STATIC_LIBRARY bson-static-1.0 PATHS "${PACKAGE_PREFIX_DIR}/lib" NO_DEFAULT_PATH)
28+
find_library (BSON_STATIC_LIBRARY bson-static-1.0 PATHS "@PACKAGE_LIBRARY_INSTALL_DIRS@" NO_DEFAULT_PATH)
3929

4030
set (BSON_STATIC_LIBRARIES ${BSON_STATIC_LIBRARY})
4131

0 commit comments

Comments
 (0)