title: How to add compiler arguments using CMake?
body: <p>I have been using the Clion IDE and am trying to get a simple GTK program to compile using it. I have found that Clion uses CMake, so the issues is here rather than with the IDE itself. I am able to successfully compile and run the program directly from the terminal but have been unsuccessful using CMake. </p>
  
  <p>The problem is simple: when I attempt to compile, the compiler cannot find gtk.h, which is located in <code>/usr/include/gtk-3.0/gtk/gtk.h</code>. I have found that somehow the command compiler argument <code>'pkg-config --libs --cflags gtk+-3.0'</code> fixes this problem but I have been unable to add this argument using CMake. </p>
  
  <p>I have tried:</p>
  
  <pre><code>set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} `pkg-config --libs --cflags gtk+-3.0`")
  </code></pre>
  
  <p>But am met with: </p>
  
  <pre><code>Linking CXX executable test
  c++: error: `pkg-config: No such file or directory
  c++: error: gtk+-3.0`: No such file or directory
  c++: error: unrecognized command line option ‘--libs’
  c++: error: unrecognized command line option ‘--cflags’
  make[3]: *** [test] Error 1
  make[2]: *** [CMakeFiles/test.dir/all] Error 2
  make[1]: *** [CMakeFiles/test.dir/rule] Error 2
  make: *** [test] Error 2
  </code></pre>
  
  <p>Any suggestions? </p>
  
  <hr>
  
  <p>Further research has revealed <a href="http://francesco-cek.com/cmake-and-gtk-3-the-easy-way/" rel="nofollow">this</a> tutorial precisely on the issue I am having. It works like a charm but appears to throw many seemingly undefined variables into the mix. Can anyone explain how and why this works? </p>
  
  <pre><code># Set the name and the supported language of the project
  project(hello-world C)
  # Set the minimum version of cmake required to build this project
  cmake_minimum_required(VERSION 2.6)
  # Use the package PkgConfig to detect GTK+ headers/library files
  find_package(PkgConfig REQUIRED)
  pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
  # Setup CMake to use GTK+, tell the compiler where to look for headers
  # and to the linker where to look for libraries
  include_directories(${GTK3_INCLUDE_DIRS})
  link_directories(${GTK3_LIBRARY_DIRS})
  # Add other flags to the compiler
  add_definitions(${GTK3_CFLAGS_OTHER})
  # Add an executable compiled from hello.c
  add_executable(hello main.c)
  # Link the target to the GTK+ libraries
  target_link_libraries(hello ${GTK3_LIBRARIES})
  </code></pre>