From 80f9ffbe507b81b89fcfbbb57b5bb6cd14f29711 Mon Sep 17 00:00:00 2001 From: vsoch Date: Fri, 15 Sep 2023 22:44:18 -0600 Subject: [PATCH] test: convert spaces to colons. If this actually works cmake... I will conjour up your evil twin, cdestroy, and release you two into the world to battle it out. No really I am just tired and writing a terrible commit message that will be squashed anyone if this weirdness actually works. Signed-off-by: vsoch --- cmake/GolangSimple.cmake | 16 ++++------------ .../reapi/bindings/go/src/test/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cmake/GolangSimple.cmake b/cmake/GolangSimple.cmake index addf06195..c3711736b 100644 --- a/cmake/GolangSimple.cmake +++ b/cmake/GolangSimple.cmake @@ -8,23 +8,15 @@ file(MAKE_DIRECTORY ${GOPATH}) # ADD_GO_INSTALLABLE_PROGRAM builds a custom go program (primarily for testing) function(BUILD_GO_PROGRAM NAME MAIN_SRC CGO_CFLAGS CGO_LIBRARY_FLAGS) message(STATUS "GOPATH: ${GOPATH}") - message(STATUS "CGO_LDFLAGS (before): ${CGO_LIBRARY_FLAGS}") - message(STATUS "TEST_FLAGS: ${TEST_FLAGS}") + message(STATUS "CGO_LDFLAGS: ${CGO_LIBRARY_FLAGS}") get_filename_component(MAIN_SRC_ABS ${MAIN_SRC} ABSOLUTE) add_custom_target(${NAME}) - # THIS IS NOT USED + # IMPORTANT: the trick to getting *spaces* to render in COMMAND is to convert them to ";" # string(REPLACE ...) - STRING(REPLACE ";" " " CGO_LDFLAGS "${CGO_LIBRARY_FLAGS}") - - # set(ENV{} []) as environment OR without CMake variable - # Note that I couldn't get this to work (the spaces are always escaped) so I hard coded for now - # We need a solution that takes the CGO_LIBRARY_FLAGS arg, and can pass (with spaces not escaped) to add_custom_command - SET ($ENV{CGO_LDFLAGS} "${CGO_LDFLAGS}") - message(STATUS "CGO_LDFLAGS (after): ${CGO_LDFLAGS}") - + STRING(REPLACE " " ";" CGO_LIBRARY_FLAGS ${CGO_LIBRARY_FLAGS}) add_custom_command(TARGET ${NAME} - COMMAND GOPATH=${GOPATH}:${CUSTOM_GO_PATH} GOOS=linux G0111MODULE=off CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS='-Wl,-R ${CMAKE_BINARY_DIR}/resource -L${CMAKE_BINARY_DIR}/resource/reapi/bindings -L${CMAKE_BINARY_DIR}/resource/libjobspec -ljobspec_conv -lreapi_cli -L${CMAKE_BINARY_DIR}/resource -lresource -lflux-idset -lstdc++ -lczmq -ljansson -lhwloc -lboost_system -lflux-hostlist -lboost_graph -lyaml-cpp' go build -ldflags '-w' + COMMAND GOPATH=${GOPATH}:${CUSTOM_GO_PATH} GOOS=linux G0111MODULE=off CGO_CFLAGS="${CGO_CFLAGS}" CGO_LDFLAGS='${CGO_LIBRARY_FLAGS}' go build -ldflags '-w' -o "${CMAKE_CURRENT_SOURCE_DIR}/${NAME}" ${CMAKE_GO_FLAGS} ${MAIN_SRC} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} diff --git a/resource/reapi/bindings/go/src/test/CMakeLists.txt b/resource/reapi/bindings/go/src/test/CMakeLists.txt index c05ddc5a1..ff4a0d5df 100644 --- a/resource/reapi/bindings/go/src/test/CMakeLists.txt +++ b/resource/reapi/bindings/go/src/test/CMakeLists.txt @@ -3,7 +3,7 @@ set(SRCS main.go) set(CGO_CFLAGS "-I${CMAKE_BINARY_DIR}/resource/reapi/bindings/c") # This is currently passed but not used because when passed into add_custom_command the spaces are escaped -set(CGO_LIBRARY_FLAGS "-L${CMAKE_BINARY_DIR}/resource/reapi/bindings;-lreapi_cli;-L${CMAKE_BINARY_DIR}/resource;-lresource;-lflux-idset;-lstdc++;-lczmq;-ljansson;-lhwloc;-lboost_system;-lflux-hostlist;-lboost_graph;-lyaml-cpp") +set(CGO_LIBRARY_FLAGS "-Wl,-R ${CMAKE_BINARY_DIR}/resource -L${CMAKE_BINARY_DIR}/resource/reapi/bindings -L${CMAKE_BINARY_DIR}/resource/libjobspec -ljobspec_conv -lreapi_cli -L${CMAKE_BINARY_DIR}/resource -lresource -lflux-idset -lstdc++ -lczmq -ljansson -lhwloc -lboost_system -lflux-hostlist -lboost_graph -lyaml-cpp") # This ensures the main binary is cleaned up set_directory_properties(