CMake, Qt and CMAKE_INCLUDE_PATH
cmake, qt
Solution
There are a couple of issues here.
I'm not sure if it's just a typo but you can't just append the instruction to set `CMAKE_INCLUDE_PATH` to the end of the `find_package` command, you need a separate `set` command:
find_package(OpenGL REQUIRED)
set(CMAKE_INCLUDE_PATH "C:\\QtSDK\\Desktop\\Qt\\4.8.0\\msvc2010\\bin")
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
Note that the path specified needs the separators to be escaped if you're using backslashes. Alternatively, you can use a single forward slash in place of the double backslash, even on Windows. Putting the path in quotes has no effect in this case, but it's a good habit to get into in case the path contains spaces.
Setting `CMAKE_INCLUDE_PATH` extends the list of paths CMake tries when doing `find_path` and `find_file` calls only. This will be useful to the `find_package` call, but even more so in this case might be to set `CMAKE_PREFIX_PATH` which extends the seach paths for all `find_XXX` commands. It does mean you'd need to strip "\bin" from the path, since it's appended to the `CMAKE_PREFIX_PATH` when searching for executables:
set(CMAKE_PREFIX_PATH "C:\\QtSDK\\Desktop\\Qt\\4.8.0\\msvc2010")
Next, `file(GLOB SOURCES "*.cpp" "*.cxx" "*.h" "*.hpp")`. While this isn't actually an error, generally it's frowned upon to use this technique to create a list of source files since if a file is added or deleted to the source tree, CMake will have no "knowledge" and won't re-run. The recommended method is to add each source file by hand to the CMakeLists.txt, so that an addition or deletion will automatically cause CMake to re-run.
Also, "`SOURCES`" is a poor choice of variable name since it also represents a property of CMake targets.
Another frowned-upon practice is the use of `link_directories`. The documentation indicates why it's not usually needed, which should be the case here.
The `add_definitions` line too may be unnecessary. Qt does define definitions, but they have already been added when you did `include(${QT_USE_FILE})` (see the documentation for FindQt4), so you're adding them twice here. I'm not familiar with Coin3 or Quarter, but they may not actually generate any required preprocessor definitions. You could check their contents by adding:
message("COIN_DEFINITIONS: ${COIN_DEFINITIONS}")
message("QUARTER_DEFINITIONS: ${QUARTER_DEFINITIONS}")
temporarily (after the corresponding `find_package` calls). If these are empty, you can delete the `add_definitions` call.
Assuming the variables `${COIN_LIBRARIES}` and `${QUARTER_LIBRARIES}` specify the full paths to these libs, then I think you should be good to go.
Problem
I found a great answer on how to get find the executable files in Qt with CMake, cmake not finding Qt4 How do you use CMAKE_INCLUDE_PATH? I tried it out, but I got an error: ``` cmake_minimum_required(VERSION 2.8) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake_modules) project(vrvu) find_package(OpenGL REQUIRED)(CMAKE_INCLUDE_PATH <--- this is where I'm getting an error C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin)find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED) include(${QT_USE_FILE}) find_package(Coin3 REQUIRED) find_package(Quarter REQUIRED) add_subdirectory(bullet-2.77) add_subdirectory(starlight) file(GLOB SOURCES "*.cpp" "*.cxx" "*.h" "*.hpp") include_directories(${OPENGL_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${COIN_INCLUDE_DIR} ${QUARTER_INCLUDE_DIR} "./bullet-2.77/src" "./starlight") link_directories(${QT_LIB_DIR} ${COIN_LINK_DIRECTORIES} ${QUARTER_LINK_DIRECTORIES}) add_definitions(${QT_DEFINITIONS} ${COIN_DEFINITIONS} ${QUARTER_DEFINITIONS}) add_executable(vrvu ${SOURCES}) target_link_libraries(vrvu ${OPENGL_LIBRARIES} ${QT_LIBRARIES} ${COIN_LIBRARIES} ${QUARTER_LIBRARIES} LinearMath BulletCollision starlight) ``` Sorry for the long code....thanks!