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: Allow to pass CFLAGS into a build dependency, when using a emb… #1985

Open
wants to merge 1 commit into
base: develop-pre-1.11.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMake/Utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ function(build_dependency lib_name)
return()
endif()

message(STATUS "CFLAGS environment variable before setting to CMAKE_C_FLAGS: $ENV{CFLAGS}")
# save original cflags to reset after build is finished for this build dependency
set(ORIG_CFLAGS $ENV{CFLAGS})

# set CFLAGS env variable since this is the only way to pass CFLAGS into a build dependency if a cross compile sdk is used (eg. Yocto)
set(ENV{CFLAGS} ${CMAKE_C_FLAGS})
message(STATUS "CFLAGS after setting to CMAKE_C_FLAGS: $ENV{CFLAGS}")

# anything after lib_name(${ARGN}) are assumed to be arguments passed over to
# library building cmake.
set(build_args ${ARGN})
Expand Down Expand Up @@ -78,6 +86,9 @@ function(build_dependency lib_name)
endif()

file(REMOVE_RECURSE ${OPEN_SRC_INSTALL_PREFIX}/lib${lib_name})

set(ENV{CFLAGS} ${ORIG_CFLAGS})
message(STATUS "CFLAGS after resetting to original CFLAGS: $ENV{CFLAGS}")
endfunction()

function(enableSanitizer SANITIZER)
Expand Down
Loading