Skip to content

Commit

Permalink
CMake packaging cleanup/fixes (#214)
Browse files Browse the repository at this point in the history
* Renamed cmake modules to avoid collisions when installed, added SOVERSION and VERSION to aws-c-common

* Use GNUInstallDirs to find where to install built libraries

* PR Feedback: leave VERSION and SOVERSION up to leaf projects
  • Loading branch information
justinboswell authored Dec 17, 2018
1 parent 7d0b1ce commit 95d9e6b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
20 changes: 13 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ project(aws-c-common C)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AwsCFlags)
include(FeatureTests)
include(Sanitizers)
include(SIMD)
include(AwsFeatureTests)
include(AwsSanitizers)
include(AwsSIMD)

set(GENERATED_ROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(GENERATED_INCLUDE_DIR "${GENERATED_ROOT_DIR}/include")
Expand Down Expand Up @@ -81,7 +81,7 @@ else ()

set(PLATFORM_LIBS pthread ${CORE_FOUNDATION_LIB})
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") # Android does not link to libpthread nor librt, so this is fine
set(PLATFORM_LIBS pthread rt)
set(PLATFORM_LIBS pthread rt)
endif()
endif()

Expand Down Expand Up @@ -119,6 +119,7 @@ if (AWS_NUM_CPU_CORES)
endif()

# Our ABI is not yet stable
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES VERSION 1.0.0)
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES SOVERSION 0unstable)

target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
Expand Down Expand Up @@ -172,6 +173,11 @@ foreach(HEADER_SRCPATH IN ITEMS ${AWS_COMMON_HEADERS} ${AWS_COMMON_OS_HEADERS} $
endforeach()

set(LIBRARY_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)
# Set the default lib installation path on GNU systems with GNUInstallDirs
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND UNIX AND NOT APPLE)
include(GNUInstallDirs)
set(LIBRARY_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
endif()

install(TARGETS ${CMAKE_PROJECT_NAME}
EXPORT ${CMAKE_PROJECT_NAME}-targets
Expand All @@ -193,9 +199,9 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
list(APPEND EXPORT_MODULES
"cmake/AwsCFlags.cmake"
"cmake/AwsTestHarness.cmake"
"cmake/LibFuzzer.cmake"
"cmake/Sanitizers.cmake"
"cmake/SIMD.cmake"
"cmake/AwsLibFuzzer.cmake"
"cmake/AwsSanitizers.cmake"
"cmake/AwsSIMD.cmake"
)

install(FILES ${EXPORT_MODULES} DESTINATION "lib/cmake/")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cmake/LibFuzzer.cmake → cmake/AwsLibFuzzer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# permissions and limitations under the License.

include(CTest)
include(Sanitizers)
include(AwsSanitizers)

option(ENABLE_FUZZ_TESTS "Build and run fuzz tests" OFF)
set(FUZZ_TESTS_MAX_TIME 60 CACHE STRING "Max time to run each fuzz test")
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmake/AwsTestHarness.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# permissions and limitations under the License.

include(AwsCFlags)
include(Sanitizers)
include(AwsSanitizers)

# Registers a test case by name (the first argument to the AWS_TEST_CASE macro in aws_test_harness.h)
macro(add_test_case name)
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include(LibFuzzer)
include(AwsLibFuzzer)
include(AwsTestHarness)
enable_testing()

Expand Down

0 comments on commit 95d9e6b

Please sign in to comment.