Skip to content

Commit

Permalink
Install DLLs to the bin directory on windows (awslabs#15)
Browse files Browse the repository at this point in the history
To avoid taking a new build-time dependency, we copy over the
AwsSharedLibSetup.cmake file from aws-c-common.
  • Loading branch information
bdonlan authored Jan 9, 2019
1 parent 9d4d04a commit 78be31b
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required (VERSION 3.1)
project (aws-checksums C)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AwsSharedLibSetup)

file(GLOB AWS_CHECKSUMS_HEADERS
"include/aws/checksums/*.h"
)
Expand Down Expand Up @@ -111,11 +114,7 @@ if (UNIX AND NOT APPLE)
endif()

install(FILES ${AWS_CHECKSUMS_HEADERS} DESTINATION "include/aws/checksums")
install(TARGETS ${CMAKE_PROJECT_NAME}
EXPORT ${CMAKE_PROJECT_NAME}-targets
ARCHIVE DESTINATION ${LIBRARY_DIRECTORY}
LIBRARY DESTINATION ${LIBRARY_DIRECTORY}
RUNTIME DESTINATION ${LIBRARY_DIRECTORY})
aws_prepare_shared_lib_exports(${CMAKE_PROJECT_NAME})

install(EXPORT "${CMAKE_PROJECT_NAME}-targets"
DESTINATION "${LIBRARY_DIRECTORY}/${CMAKE_PROJECT_NAME}/cmake/"
Expand Down
63 changes: 63 additions & 0 deletions cmake/AwsSharedLibSetup.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

set(LIBRARY_DIRECTORY lib)
set(RUNTIME_DIRECTORY bin)
# Set the default lib installation path on GNU systems with GNUInstallDirs
if (UNIX AND NOT APPLE)
include(GNUInstallDirs)
set(LIBRARY_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
set(RUNTIME_DIRECTORY ${CMAKE_INSTALL_BINDIR})

# this is the absolute dumbest thing in the world, but find_package won't work without it
# also I verified this is correctly NOT "lib64" when CMAKE_C_FLAGS includes "-m32"
if (${LIBRARY_DIRECTORY} STREQUAL "lib64")
set(FIND_LIBRARY_USE_LIB64_PATHS true)
endif()
endif()


function(aws_prepare_shared_lib_exports target)
if (BUILD_SHARED_LIBS)
install(TARGETS ${target}
EXPORT ${target}-targets
ARCHIVE
DESTINATION ${LIBRARY_DIRECTORY}
COMPONENT Development
LIBRARY
DESTINATION ${LIBRARY_DIRECTORY}
NAMELINK_SKIP
COMPONENT Runtime
RUNTIME
DESTINATION ${RUNTIME_DIRECTORY}
COMPONENT Runtime)
install(TARGETS ${target}
EXPORT ${target}-targets
LIBRARY
DESTINATION ${LIBRARY_DIRECTORY}
NAMELINK_ONLY
COMPONENT Development)
else()
install(TARGETS ${target}
EXPORT ${target}-targets
ARCHIVE DESTINATION ${LIBRARY_DIRECTORY}
COMPONENT Development)
endif()
endfunction()

function(aws_prepare_symbol_visibility_args target lib_prefix)
if (BUILD_SHARED_LIBS)
target_compile_definitions(${target} PUBLIC "-D${lib_prefix}_USE_IMPORT_EXPORT")
target_compile_definitions(${target} PRIVATE "-D${lib_prefix}_EXPORTS")
endif()
endfunction()

0 comments on commit 78be31b

Please sign in to comment.