[cmake] unify CFLAGS to string

* move to common CMake function
* escape CFLAGS
This commit is contained in:
akallabeth 2024-10-24 16:27:07 +02:00
parent a3aa01214c
commit a27d9508e2
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
4 changed files with 17 additions and 15 deletions

11
cmake/CFlagsToVar.cmake Normal file
View File

@ -0,0 +1,11 @@
function(CFlagsToVar NAME)
set(C_FLAGS ${CMAKE_C_FLAGS})
if (CMAKE_BUILD_TYPE)
string(TOUPPER "${CMAKE_BUILD_TYPE}" CAPS_BUILD_TYPE)
string(APPEND C_FLAGS " ${CMAKE_C_FLAGS_${CAPS_BUILD_TYPE}}")
endif()
string(REPLACE "\$" "\\\$" C_FLAGS "${C_FLAGS}")
string(REPLACE "\"" "\\\"" C_FLAGS "${C_FLAGS}")
set(${NAME} ${C_FLAGS} PARENT_SCOPE)
endfunction()

View File

@ -38,11 +38,8 @@ if (WIN32)
string(REPLACE "\\" "\\\\" NATIVE_FREERDP_PROXY_PLUGINDIR "${NATIVE_FREERDP_PROXY_PLUGINDIR}")
endif()
set(C_FLAGS ${CMAKE_C_FLAGS})
if (CMAKE_BUILD_TYPE)
string(TOUPPER "${CMAKE_BUILD_TYPE}" CAPS_BUILD_TYPE)
string(APPEND C_FLAGS " ${CMAKE_C_FLAGS_${CAPS_BUILD_TYPE}}")
endif()
include(CFlagsToVar)
CFlagsToVar(C_FLAGS)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/version.h)
cleaning_configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp/build-config.h)

View File

@ -33,11 +33,8 @@ FOREACH(var ${res})
ENDIF()
ENDFOREACH()
set(C_FLAGS ${CMAKE_C_FLAGS})
if (CMAKE_BUILD_TYPE)
string(TOUPPER "${CMAKE_BUILD_TYPE}" CAPS_BUILD_TYPE)
string(APPEND C_FLAGS " ${CMAKE_C_FLAGS_${CAPS_BUILD_TYPE}}")
endif()
include(CFlagsToVar)
CFlagsToVar(C_FLAGS)
string(REPLACE ";" " " UWAC_BUILD_CONFIG "${UWAC_BUILD_CONFIG_LIST}")
cleaning_configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/../include/uwac/version.h)

View File

@ -15,11 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set(C_FLAGS ${CMAKE_C_FLAGS})
if (CMAKE_BUILD_TYPE)
string(TOUPPER "${CMAKE_BUILD_TYPE}" CAPS_BUILD_TYPE)
string(APPEND C_FLAGS " ${CMAKE_C_FLAGS_${CAPS_BUILD_TYPE}}")
endif()
include(CFlagsToVar)
CFlagsToVar(C_FLAGS)
cleaning_configure_file(config/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/version.h)
cleaning_configure_file(config/wtypes.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/wtypes.h)