Skip to content

Commit

Permalink
Merge pull request #24 from awslabs/in_source_build
Browse files Browse the repository at this point in the history
enabled in-source build.
  • Loading branch information
JonathanHenson authored Jan 2, 2020
2 parents 704f364 + 1fd562c commit 8e9caac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
39 changes: 20 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")
include(AwsCFlags)
include(AwsSharedLibSetup)
include(AwsSanitizers)
include(AwsFindPackage)

file(GLOB AWS_CAL_HEADERS
"include/aws/cal/*.h"
Expand Down Expand Up @@ -99,36 +100,36 @@ file(GLOB CAL_SRC
${AWS_CAL_OS_SRC}
)

add_library(${CMAKE_PROJECT_NAME} ${CAL_SRC})
aws_set_common_properties(${CMAKE_PROJECT_NAME} NO_WEXTRA)
aws_prepare_symbol_visibility_args(${CMAKE_PROJECT_NAME} "AWS_CAL")
aws_add_sanitizers(${CMAKE_PROJECT_NAME} BLACKLIST "sanitizer-blacklist.txt")
add_library(${PROJECT_NAME} ${CAL_SRC})
aws_set_common_properties(${PROJECT_NAME} NO_WEXTRA)
aws_prepare_symbol_visibility_args(${PROJECT_NAME} "AWS_CAL")
aws_add_sanitizers(${PROJECT_NAME} BLACKLIST "sanitizer-blacklist.txt")

find_package(aws-c-common REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC AWS::aws-c-common ${PLATFORM_LIBS})
aws_use_package(aws-c-common)
target_link_libraries(${PROJECT_NAME} PUBLIC AWS::aws-c-common ${PLATFORM_LIBS} ${DEP_AWS_LIBS})

if (BYO_CRYPTO)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE -DAWS_BYO_CRYPTO)
target_compile_definitions(${PROJECT_NAME} PRIVATE -DAWS_BYO_CRYPTO)
elseif (NOT WIN32 AND NOT APPLE)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE $<TARGET_PROPERTY:LibCrypto::Crypto,INTERFACE_INCLUDE_DIRECTORIES>)
target_include_directories(${PROJECT_NAME} PRIVATE $<TARGET_PROPERTY:LibCrypto::Crypto,INTERFACE_INCLUDE_DIRECTORIES>)
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)
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 1.0.0)
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 0unstable)

target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
# When we install, the generated header will be at the INSTALL_INTERFACE:include location,
# but at build time we need to explicitly include this here
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${GENERATED_INCLUDE_DIR}>)

aws_prepare_shared_lib_exports(${CMAKE_PROJECT_NAME})
aws_prepare_shared_lib_exports(${PROJECT_NAME})

configure_file("cmake/${CMAKE_PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
configure_file("cmake/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
@ONLY)

install(FILES ${AWS_CAL_HEADERS} DESTINATION "include/aws/cal" COMPONENT Development)
Expand All @@ -139,13 +140,13 @@ else()
set (TARGET_DIR "static")
endif()

install(EXPORT "${CMAKE_PROJECT_NAME}-targets"
DESTINATION "${LIBRARY_DIRECTORY}/${CMAKE_PROJECT_NAME}/cmake/${TARGET_DIR}/"
install(EXPORT "${PROJECT_NAME}-targets"
DESTINATION "${LIBRARY_DIRECTORY}/${PROJECT_NAME}/cmake/${TARGET_DIR}/"
NAMESPACE AWS::
COMPONENT Development)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake"
DESTINATION "${LIBRARY_DIRECTORY}/${CMAKE_PROJECT_NAME}/cmake"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${LIBRARY_DIRECTORY}/${PROJECT_NAME}/cmake"
COMPONENT Development)

list(APPEND EXPORT_MODULES
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ add_test_case(sha256_hmac_test_oneshot)
add_test_case(sha256_hmac_test_invalid_buffer)
add_test_case(sha256_hmac_test_invalid_state)

generate_test_driver(${CMAKE_PROJECT_NAME}-tests)
generate_test_driver(${PROJECT_NAME}-tests)

0 comments on commit 8e9caac

Please sign in to comment.