summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorSteve Youngs <steve@sxemacs.org>2021-07-04 12:31:42 +0300
committerIvan Maidanski <ivmai@mail.ru>2021-07-08 15:00:13 +0300
commitfe4ed5af3ab9b370cf03497d3796a65089f1bbe5 (patch)
tree838a90d3b3a4cf5ab7aba545ebc456c7f3ca6f21 /CMakeLists.txt
parent596a34c0ea4a720db0ac61b33a8eac10b02837b9 (diff)
downloadbdwgc-fe4ed5af3ab9b370cf03497d3796a65089f1bbe5.tar.gz
Generate pkg-config metadata file (CMake)
Issue #356 (bdwgc). bdw-gc.pc file is generated and copied to $libdir/pkgconfig/ but only if enable_threads (on by default). * CMakeLists.txt (PACKAGE_VERSION): Define variable (to 8.1.0, same as in configure.ac). * CMakeLists.txt (install_headers): Update description. * CMakeLists.txt (ATOMIC_OPS_LIBS): Define to empty; add TODO item. * CMakeLists.txt [enable_threads] (target_link_libraries(gc)): Add $ATOMIC_OPS_LIBS. * CMakeLists.txt [install_headers] (prefix, exec_prefix, libdir, includedir): Define variable. * CMakeLists.txt [install_headers]: Generate bdw-gc.pc file (using configure_file) and install it.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt20
1 files changed, 18 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c2df8e6f..ee4f926f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,10 @@
cmake_minimum_required(VERSION 3.1)
+set(PACKAGE_VERSION 8.1.0)
+# Version must match that in AC_INIT of configure.ac and that in README.
+# Version must conform to: [0-9]+[.][0-9]+[.][0-9]+
+
option(enable_cplusplus "C++ support" OFF)
if (enable_cplusplus)
project(gc)
@@ -67,7 +71,7 @@ option(enable_werror "Pass -Werror to the C compiler (treat warnings as errors)"
option(enable_single_obj_compilation "Compile all libgc source files into single .o" OFF)
option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON)
option(disable_handle_fork "Prohibit installation of pthread_atfork() handlers" OFF)
-option(install_headers "Install header files" ON)
+option(install_headers "Install header and pkg-config metadata files" ON)
add_definitions("-DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION")
@@ -123,6 +127,8 @@ if (enable_threads)
endif()
endif(enable_threads)
+set(ATOMIC_OPS_LIBS "") # TODO: Assume libatomic_ops library is not needed.
+
# Thread support detection.
if (CMAKE_USE_PTHREADS_INIT)
set(SRC ${SRC} gc_dlopen.c pthread_start.c pthread_stop_world.c
@@ -420,7 +426,7 @@ endif()
add_library(gc ${SRC})
if (enable_threads)
- target_link_libraries(gc PRIVATE ${THREADDLLIBS})
+ target_link_libraries(gc PRIVATE ${THREADDLLIBS} ${ATOMIC_OPS_LIBS})
endif()
if (enable_cplusplus)
@@ -512,6 +518,16 @@ if (install_headers)
include/ec.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/gc")
endif()
+
+ # Provide pkg-config metadata.
+ set(prefix "${CMAKE_INSTALL_PREFIX}")
+ set(exec_prefix \${prefix})
+ set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
+ set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
+ # ATOMIC_OPS_LIBS, PACKAGE_VERSION, THREADDLLIBS are defined above.
+ configure_file(bdw-gc.pc.in bdw-gc.pc @ONLY)
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/bdw-gc.pc"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif(install_headers)
if (build_tests)