Skip to content

Commit

Permalink
Update go.cmake to use PROJECT_SOURCE_DIR (#1484)
Browse files Browse the repository at this point in the history
Update go.cmake to use PROJECT_SOURCE_DIR to enable customers to build AWS-LC as a CMake sub_directory. Resolves P120917801.
  • Loading branch information
andrewhop authored Mar 9, 2024
1 parent 74feede commit 37708f5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmake/go.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if(NOT GO_EXECUTABLE AND NOT DISABLE_GO)
endif()

function(go_executable dest package)
set(godeps "${CMAKE_SOURCE_DIR}/util/godeps.go")
set(godeps "${PROJECT_SOURCE_DIR}/util/godeps.go")
if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
# The DEPFILE parameter to add_custom_command only works with Ninja. Query
# the sources at configure time. Additionally, everything depends on go.mod.
Expand All @@ -32,7 +32,7 @@ function(go_executable dest package)
COMMAND ${GO_EXECUTABLE} build
-o ${CMAKE_CURRENT_BINARY_DIR}/${dest} ${package}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${sources} ${CMAKE_SOURCE_DIR}/go.mod)
DEPENDS ${sources} ${PROJECT_SOURCE_DIR}/go.mod)
else()
# Ninja expects the target in the depfile to match the output. This is a
# relative path from the build directory.
Expand All @@ -52,7 +52,7 @@ function(go_executable dest package)
COMMAND ${GO_EXECUTABLE} build
-o ${CMAKE_CURRENT_BINARY_DIR}/${dest} ${package}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${CMAKE_SOURCE_DIR}/go.mod)
DEPENDS ${PROJECT_SOURCE_DIR}/go.mod)
else()
set(depfile "${CMAKE_CURRENT_BINARY_DIR}/${dest}.d")
add_custom_command(OUTPUT ${dest}
Expand All @@ -61,7 +61,7 @@ function(go_executable dest package)
COMMAND ${GO_EXECUTABLE} run ${godeps} -format depfile
-target ${target} -pkg ${package} -out ${depfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${godeps} ${CMAKE_SOURCE_DIR}/go.mod
DEPENDS ${godeps} ${PROJECT_SOURCE_DIR}/go.mod
DEPFILE ${depfile})
endif()
endif()
Expand Down

0 comments on commit 37708f5

Please sign in to comment.