[CMake] how to define the output location of QT4_WRAP_UI?

John Drescher drescherjm at gmail.com
Tue Jan 26 17:50:01 EST 2010


On Tue, Jan 26, 2010 at 5:39 PM, eial at cs.bgu.ac.il <eial at cs.bgu.ac.il> wrote:
>
> hello.
> I've ran into a slight problem, I have a program that uses qt4 gui, I've created classes with ui, my cmakelist.txts looks like this:
>
> cmake_minimum_required(VERSION 2.6)
> PROJECT(Quad)
>
> SET(CMAKE_VERBOSE_MAKEFILE ON)
> SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build)
> SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/build/libs)
> SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/modules)
> SET(Boost_MINIMUM_VERSION "1.33.1")
> find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
> #INCLUDE(${QT_cd USE_FILE})
> INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR} src)
>
> SUBDIRS(src)
>
> and
>
> #this is just a basic CMakeLists.txt, for more information see the cmake manpage
>
> SET(SUBDIRS GUI Utilities DataObjects Threads)
> FOREACH(subdir ${SUBDIRS})
>  add_subdirectory(${subdir})
> ENDFOREACH(subdir)
>
> #add definitions, compiler switches, etc.
> ADD_DEFINITIONS(-g -Wall -O2)
>
> #get all cpp files in libs
> file(GLOB UTIL_CPP Utilities/*.cpp)
> file(GLOB DATA_CPP DataObjects/*.cpp)
> file(GLOB THREADS_CPP Threads/*.cpp)
> file(GLOB GUI_CPP GUI/*.cpp)
> file(GLOB GUI_UI GUI/*.ui)
>
> QT4_WRAP_UI(GUI_UI_H ${GUI_UI})
>
> #build a shared library
> ADD_LIBRARY(Utilities SHARED ${UTIL_CPP})
> ADD_LIBRARY(DataObjects SHARED ${DATA_CPP})
> ADD_LIBRARY(Threads SHARED ${THREADS_CPP})
> ADD_LIBRARY(GUI SHARED ${GUI_CPP} ${GUI_UI_H})
>
> #add_subdirectory(testUnits)
> #link libs
> target_link_libraries(DataObjects)
> target_link_libraries(Utilities DataObjects)
> target_link_libraries(Threads Utilities DataObjects)
> target_link_libraries(GUI ${QT_QTCORE_LIBRARIES} ${QT_QTGUI_LIBRARIES} Utilities DataObjects)
>
> #list all source files here
> ADD_EXECUTABLE(Quad Quad.cpp)
>
> #need to link to some other libraries
> TARGET_LINK_LIBRARIES(Quad DataObjects Utilities Threads GUI)
>
> now for some reason the ui_*.h files are created under the bin folder causing compilation to fail because these files are missing in the actual src folder.
>
> how can I define the macro's output location?
>

The point of out of source builds is nothing generated goes with the
source. I would just add the binary folder as an include using cmake.

INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})

John


More information about the CMake mailing list