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

CMAKE_C?_FLAGS are not lists but strings #191

Open
RJVB opened this issue Aug 8, 2023 · 3 comments
Open

CMAKE_C?_FLAGS are not lists but strings #191

RJVB opened this issue Aug 8, 2023 · 3 comments

Comments

@RJVB
Copy link

RJVB commented Aug 8, 2023

list(APPEND CMAKE_C_FLAGS ${FLAGS})

CMake lists are semicolon-separated affairs so appending flags to CMAKE_C?_FLAGS with list(APPEND CMAKE_C?_FLAGS "-foo -bar") will introduce a semicolon in the final compiler invocation if those flags aren't empty. Which can be the case if the user calls CMake with CFLAGS and/or CXXFLAGS in the environment.

The proper way to append compiler flags is a string append operation, e.g.

if(CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
  set(FLAGS " -w -Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
endif()
@jvoisin
Copy link
Collaborator

jvoisin commented Aug 8, 2023

Care to send a pull-request?

@RJVB
Copy link
Author

RJVB commented Aug 8, 2023

Really, for such a small & trivial change?

mjp41 added a commit to mjp41/mimalloc-bench that referenced this issue Aug 8, 2023
Fixes CMAKE_C?_FLAGS are not lists but strings daanx#191
@mjp41 mjp41 mentioned this issue Aug 8, 2023
@mjp41
Copy link
Collaborator

mjp41 commented Aug 8, 2023

I had the files open, so pushed a PR. #192

mjp41 added a commit that referenced this issue Aug 9, 2023
Fixes CMAKE_C?_FLAGS are not lists but strings #191
derSteFfi pushed a commit to derSteFfi/mimalloc-bench that referenced this issue Sep 7, 2023
Fixes CMAKE_C?_FLAGS are not lists but strings daanx#191
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

3 participants