From 97b9fd6c3f61079099557201b697e8f0af12b4ff Mon Sep 17 00:00:00 2001 From: Victor Romero Date: Fri, 7 Jun 2019 09:34:27 +0300 Subject: [PATCH] Support header files installation in CMake script Issue #281 (bdwgc). Now, "cmake --target install" copies the public header files (to the installation destination) unless -Dinstall_headers=OFF is passed to cmake. * CMakeLists.txt (install_headers): New option (on by default). * CMakeLists.txt [install_headers] (include/gc.h, include/gc_backptr.h, include/gc_config_macros.h, include/gc_gcj.h, include/gc_inline.h, include/gc_mark.h, include/gc_pthread_redirects.h, include/gc_tiny_fl.h, include/gc_typed.h, include/gc_version.h, include/javaxfc.h, include/leak_detector.h): Specify install to "include/gc" folder. * CMakeLists.txt [install_headers && enable_cplusplus] (include/gc_allocator.h, include/gc_cpp.h): Likewise. * CMakeLists.txt [install_headers && enable_disclaim] (include/gc_disclaim.h): Likewise. * CMakeLists.txt [install_headers] (include/extra/gc.h): Specify install to "include" folder. * CMakeLists.txt [install_headers && enable_cplusplus] (include/extra/gc_cpp.h): Likewise. --- CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4175e07a0..f70041d3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ option(enable_dynamic_loading "Enable tracing of dynamic library data roots" ON) option(enable_register_main_static_data "Perform the initial guess of data root sets" ON) option(enable_checksums "Report erroneously cleared dirty bits" OFF) option(enable_handle_fork "Attempt to ensure a usable collector after fork()" ON) +option(install_headers "Install header files" ON) add_definitions("-DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION") @@ -260,6 +261,33 @@ if (build_cord) add_subdirectory(cord) endif() +if (install_headers) + install(FILES include/gc.h + include/gc_backptr.h + include/gc_config_macros.h + include/gc_gcj.h + include/gc_inline.h + include/gc_mark.h + include/gc_pthread_redirects.h + include/gc_tiny_fl.h + include/gc_typed.h + include/gc_version.h + include/javaxfc.h + include/leak_detector.h + DESTINATION include/gc) + install(FILES include/extra/gc.h DESTINATION include) + if (enable_cplusplus) + install(FILES include/gc_allocator.h + include/gc_cpp.h + DESTINATION include/gc) + install(FILES include/extra/gc_cpp.h DESTINATION include) + endif(enable_cplusplus) + if (enable_disclaim) + install(FILES include/gc_disclaim.h DESTINATION include/gc) + endif(enable_disclaim) + # TODO if build_cord then install cord.h, cord_pos.h, ec.h +endif() + if (build_tests) add_subdirectory(tests) endif()