Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list_expansion: favour-expansion is not respected in each case? #47

Closed
ClausKlein opened this issue Dec 9, 2024 · 2 comments
Closed

Comments

@ClausKlein
Copy link

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b01e1e3..dc6ac3a 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -55,18 +55,12 @@ if(NOT PROJECT_IS_TOP_LEVEL)
   if(CMAKE_BUILD_TYPE STREQUAL Debug)
     add_test(
       NAME find-package-test
-      COMMAND ${CMAKE_CTEST_COMMAND}
-        --verbose
-        --output-on-failure -C Debug
-        --build-and-test
-          "${CMAKE_SOURCE_DIR}/module/tests" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test"
-        --build-generator ${CMAKE_GENERATOR}
-        --build-makeprogram ${CMAKE_MAKE_PROGRAM}
-        --build-options
-          "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
-          "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
-          "-DCMAKE_BUILD_TYPE=Debug"
-          "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
+      COMMAND
+        ${CMAKE_CTEST_COMMAND} --verbose --output-on-failure -C Debug --build-and-test
+        "${CMAKE_SOURCE_DIR}/module/tests" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" --build-generator
+        ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options
+        "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
+        "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
     )
   endif()
   # cmake-format: on
bash-5.2$ 
``
@BlankSpruce
Copy link
Owner

I don't mention it explicitly but it's by design and it's visible in example for favour-expansion:

add_custom_command(
    OUTPUT
        ${SOMETHING_TO_OUTPUT}
    COMMAND
        ${CMAKE_COMMAND} -E cat foobar
    COMMAND
        cmake -E echo foobar
    COMMAND
        cmake -E echo "something quite a bit                           longer"
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/something
    DEPENDS
        ${CMAKE_CURRENT_SOURCE_DIR}/something
        ${CMAKE_CURRENT_SOURCE_DIR}/something_else
    COMMENT "example custom command"
)

The choice is deliberate to have COMMAND and COMMAND-like keywords to behave this way because on average it seems to have better readability instead of blowing all arguments in separate line. It's also supported way of formatting for custom commands which have command_line hint in their definition. There's also an easy way to force line break in such case with empty comment:

add_custom_command(
    OUTPUT
        ${SOMETHING_TO_OUTPUT}
    COMMAND
        some_command --with-option-one foo --with-option-two bar --with-set-of-things foo bar baz
    COMMAND
        some_command # 
        --with-option-one foo #
        --with-option-two bar # 
        --with-set-of-things foo bar baz
)

Having said all that I'll have to extend README to explain this deliberate choice along with listing of command-keyword pairs for which it's applicable out of the box. I'll update README soon-ish.

@BlankSpruce
Copy link
Owner

I've expanded description of style in README to explain this behaviour and to provide a hint of forcing particular expansion pattern with empty comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants