Skip to content

Commit

Permalink
CMake Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm committed Dec 23, 2024
1 parent bf9b2ea commit 1931fe5
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This library is licensed under the Apache 2.0 License.

- `dotnet build -f netstandard2.0 -p:PlatformTarget=x64 -p:CMakeConfig=Debug` for 64 bit mac machine. Check ./builder.json for `PlatformTarget` on your machine.
- `dotnet pack -p:TargetFrameworks=netstandard2.0`
- OR run `chmod a+x ./clean_rebuild.sh && ./clean_rebuild.sh`, which will clean up the previous build and rebuild the project from source.
- OR run `./clean_rebuild.sh`, which will clean up the previous build and rebuild the project from source.

### Test steps

Expand Down
2 changes: 1 addition & 1 deletion crt/aws-c-auth
2 changes: 1 addition & 1 deletion crt/aws-lc
2 changes: 1 addition & 1 deletion crt/s2n
Submodule s2n updated from ffe0bf to 493b77
36 changes: 4 additions & 32 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.9...3.31)

project(aws-crt-dotnet C)
option(BUILD_DEPS "Builds aws common runtime dependencies as part of build" ON)

if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) # Enable options to get their values from normal variables
endif()

if (DEFINED CMAKE_PREFIX_PATH)
file(TO_CMAKE_PATH ${CMAKE_PREFIX_PATH} CMAKE_PREFIX_PATH)
endif()

if (DEFINED CMAKE_INSTALL_PREFIX)
file(TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX} CMAKE_INSTALL_PREFIX)
endif()


if (UNIX AND NOT APPLE)
include(GNUInstallDirs)
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake")

if (${CMAKE_INSTALL_LIBDIR} STREQUAL "lib64")
set(FIND_LIBRARY_USE_LIB64_PATHS true)
endif()

if (NOT WIN32 AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

# This is required in order to append /lib/cmake to each element in CMAKE_PREFIX_PATH
set(AWS_MODULE_DIR "/${CMAKE_INSTALL_LIBDIR}/cmake")
string(REPLACE ";" "${AWS_MODULE_DIR};" AWS_MODULE_PATH "${CMAKE_PREFIX_PATH}${AWS_MODULE_DIR}")
# Append that generated list to the module search path
list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH})

if (BUILD_DEPS)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../crt/aws-c-common/cmake")
message(STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}")
Expand Down Expand Up @@ -85,6 +54,9 @@ if (BUILD_DEPS)
add_subdirectory(../crt/aws-c-auth ${CMAKE_BINARY_DIR}/deps/aws-c-auth)
add_subdirectory(../crt/aws-checksums ${CMAKE_BINARY_DIR}/deps/aws-checksums)
else()
# this is required so we can use aws-c-common's CMake modules
find_package(aws-c-common REQUIRED)

include(AwsFindPackage)
set(IN_SOURCE_BUILD OFF)
endif()
Expand Down

0 comments on commit 1931fe5

Please sign in to comment.