Skip to content

Commit 491b299

Browse files
committed
cmake: Disable SECP256K1_APPEND_*FLAGS options for VS generators
The "Visual Studio" generators create project files in a way that does not use low-level rule variables. Consequently, setting `SECP256K1_APPEND_*FLAGS` has no effect. Disabling these options ensures that CMake warns the user if any of them are set.
1 parent f79f46c commit 491b299

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

CMakeLists.txt

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,21 @@ if(SECP256K1_BUILD_CTIME_TESTS)
280280
unset(msan_enabled)
281281
endif()
282282

283-
set(SECP256K1_APPEND_CFLAGS "" CACHE STRING "Compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.")
284-
if(SECP256K1_APPEND_CFLAGS)
285-
# Appending to this low-level rule variable is the only way to
286-
# guarantee that the flags appear at the end of the command line.
287-
string(APPEND CMAKE_C_COMPILE_OBJECT " ${SECP256K1_APPEND_CFLAGS}")
288-
endif()
283+
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
284+
set(SECP256K1_APPEND_CFLAGS "" CACHE STRING "Compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.")
285+
if(SECP256K1_APPEND_CFLAGS)
286+
# Appending to this low-level rule variable is the only way to
287+
# guarantee that the flags appear at the end of the command line.
288+
string(APPEND CMAKE_C_COMPILE_OBJECT " ${SECP256K1_APPEND_CFLAGS}")
289+
endif()
289290

290-
set(SECP256K1_APPEND_LDFLAGS "" CACHE STRING "Linker flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.")
291-
if(SECP256K1_APPEND_LDFLAGS)
292-
# Appending to this low-level rule variable is the only way to
293-
# guarantee that the flags appear at the end of the command line.
294-
string(APPEND CMAKE_C_CREATE_SHARED_LIBRARY " ${SECP256K1_APPEND_LDFLAGS}")
295-
string(APPEND CMAKE_C_LINK_EXECUTABLE " ${SECP256K1_APPEND_LDFLAGS}")
291+
set(SECP256K1_APPEND_LDFLAGS "" CACHE STRING "Linker flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.")
292+
if(SECP256K1_APPEND_LDFLAGS)
293+
# Appending to this low-level rule variable is the only way to
294+
# guarantee that the flags appear at the end of the command line.
295+
string(APPEND CMAKE_C_CREATE_SHARED_LIBRARY " ${SECP256K1_APPEND_LDFLAGS}")
296+
string(APPEND CMAKE_C_LINK_EXECUTABLE " ${SECP256K1_APPEND_LDFLAGS}")
297+
endif()
296298
endif()
297299

298300
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
@@ -381,11 +383,13 @@ else()
381383
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
382384
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
383385
endif()
384-
if(SECP256K1_APPEND_CFLAGS)
385-
message("SECP256K1_APPEND_CFLAGS ............... ${SECP256K1_APPEND_CFLAGS}")
386-
endif()
387-
if(SECP256K1_APPEND_LDFLAGS)
388-
message("SECP256K1_APPEND_LDFLAGS .............. ${SECP256K1_APPEND_LDFLAGS}")
386+
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
387+
if(SECP256K1_APPEND_CFLAGS)
388+
message("SECP256K1_APPEND_CFLAGS ............... ${SECP256K1_APPEND_CFLAGS}")
389+
endif()
390+
if(SECP256K1_APPEND_LDFLAGS)
391+
message("SECP256K1_APPEND_LDFLAGS .............. ${SECP256K1_APPEND_LDFLAGS}")
392+
endif()
389393
endif()
390394
message("")
391395
if(print_msan_notice)

0 commit comments

Comments
 (0)