[CMake] include_directories question

Michael Surette mjsurette at gmail.com
Sun Jan 31 13:09:33 EST 2016


I have the following CMakeLists file which builds one of the examples in 
FLTK as a separate project.

---
cmake_minimum_required(VERSION 2.6)

project(CubeView)

set(FLTK_DIR /home/msurette/build/fltk-release/)

find_package(FLTK REQUIRED NO_MODULE)
include(${FLTK_USE_FILE})

#run fluid -c to generate cxx and h files
add_custom_command(
	OUTPUT "CubeViewUI.cxx" "CubeViewUI.h"
	COMMAND fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/CubeViewUI.fl
)

include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR})
add_executable(CubeView WIN32 CubeMain.cxx  CubeView.cxx  CubeViewUI.cxx)

target_link_libraries(CubeView fltk fltk_gl)
---

It works well, but not without the two include_directories commands.

Could someone please explain to me why they are necessary,

Seeing as the custom command deposits its results in CMAKE_BINARY_DIR I 
would expect it to be searched for source and header files.

CMAKE_SOURCE_DIR should always be searched for source and header files, 
shouldn't it?

Mike



More information about the CMake mailing list