title: Using execute_process and OUTPUT_VARIABLE in CMake
body: <p>I want to add libpqxx library to my project, but find_package doesn't seem work with it. So I decided to manually add pkg-config's output on libpqxx to compiler and linker flags. For some reason this doesn't work (I tried building with CLion and from terminal, they both failed but with different errors). But if I simply insert pkg-config's output manually, then everything works fine.</p>
  <pre><code>execute_process (COMMAND bash -c &quot;pkg-config --cflags libpqxx&quot; OUTPUT_VARIABLE libs_cflags)
  execute_process (COMMAND bash -c &quot;pkg-config --libs libpqxx&quot; OUTPUT_VARIABLE libs_linker_flags)
  
  # Prints 'flags ='
  execute_process (COMMAND bash -c &quot;echo flags = ${CMAKE_CXX_FLAGS}&quot;)
  
  # Works fine
  #set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} -I/opt/homebrew/Cellar/libpqxx/7.7.0/include&quot;)
  
  # Doesn't work
  set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} ${libs_cflags}&quot;)
  
  # Prints 'flags=-I/opt/homebrew/Cellar/libpqxx/7.7.0/include'
  execute_process (COMMAND bash -c &quot;echo flags = ${CMAKE_CXX_FLAGS}&quot;)
  
  # Works fine
  #set(CMAKE_EXE_LINKER_FLAGS &quot;${CMAKE_EXE_LINKER_FLAGS} -L/opt/homebrew/Cellar/libpqxx/7.7.0/lib -lpqxx&quot;)
  
  # Doesn't work
  set(CMAKE_EXE_LINKER_FLAGS &quot;${CMAKE_EXE_LINKER_FLAGS} ${libs_linker_flags}&quot;)
  
  </code></pre>