@@ -10,7 +10,8 @@ add_library(hashmap
1010 src/hashmap.c
1111)
1212
13- # Add an alias so that library can be used inside the build tree, e.g. when testing
13+ # Add an alias so that library can be used inside the build tree,
14+ # e.g. when testing
1415add_library (HashMap::HashMap ALIAS hashmap)
1516
1617# Set target properties
@@ -21,8 +22,9 @@ target_include_directories(hashmap
2122 PRIVATE
2223 ${CMAKE_CURRENT_SOURCE_DIR} /src
2324)
24-
25- target_compile_options (hashmap PRIVATE $<$<C_COMPILER_ID:GNU>:-Wall -Werror>)
25+ target_compile_options (hashmap
26+ PRIVATE $<$<C_COMPILER_ID:GNU>:-Wall -Werror>
27+ )
2628
2729##############################################
2830# Installation instructions
@@ -36,19 +38,24 @@ install(TARGETS hashmap
3638 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
3739)
3840
39- # This is required so that the exported target has the name HashMap and not hashmap
40- set_target_properties (hashmap PROPERTIES EXPORT_NAME HashMap)
41+ # Ensurethe exported target has the name HashMap and not hashmap
42+ # and if this is linked into a shared library, ensure it is PIC
43+ set_target_properties (hashmap
44+ PROPERTIES
45+ EXPORT_NAME HashMap
46+ POSITION_INDEPENDENT_CODE ON
47+ )
4148
4249install (DIRECTORY include / DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
4350
4451# Export the targets to a script
4552install (EXPORT hashmap-targets
46- FILE
47- HashMapTargets.cmake
48- NAMESPACE
49- HashMap::
50- DESTINATION
51- ${INSTALL_CONFIGDIR}
53+ FILE
54+ HashMapTargets.cmake
55+ NAMESPACE
56+ HashMap::
57+ DESTINATION
58+ ${INSTALL_CONFIGDIR}
5259)
5360
5461# Create a ConfigVersion.cmake file
@@ -59,7 +66,8 @@ write_basic_package_version_file(
5966 COMPATIBILITY AnyNewerVersion
6067)
6168
62- configure_package_config_file(${CMAKE_CURRENT_LIST_DIR} /cmake/HashMapConfig.cmake.in
69+ configure_package_config_file(
70+ ${CMAKE_CURRENT_LIST_DIR} /cmake/HashMapConfig.cmake.in
6371 ${CMAKE_CURRENT_BINARY_DIR} /HashMapConfig.cmake
6472 INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
6573)
@@ -72,8 +80,11 @@ install(FILES
7280)
7381
7482##############################################
75- ## Exporting from the build tree
76- export (EXPORT hashmap-targets FILE ${CMAKE_CURRENT_BINARY_DIR} /HashMapTargets.cmake NAMESPACE HashMap::)
83+ # Exporting from the build tree
84+ export (EXPORT hashmap-targets
85+ FILE ${CMAKE_CURRENT_BINARY_DIR} /HashMapTargets.cmake
86+ NAMESPACE HashMap::
87+ )
7788
78- #Register package in user's package registry
89+ # Register package in user's package registry
7990export (PACKAGE HashMap)
0 commit comments