c++qtcmakeqt3

How could I execute the exe(uic of Qt3) by cmake


I am trying to call the uic of Qt3(maintaining legacy codes), but fail to do so.Following is my make file

project(testQt3)
cmake_minimum_required(VERSION 2.8.11)

set(PROJECT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../project)
set(PROJECT_ARCH $ENV{MAKEOBJDIR})

set(CMAKE_BUILD_TYPE Release)

aux_source_directory(. SRC_LIST)

add_executable(${PROJECT_NAME} ${SRC_LIST})  

set(Qt3DirPath ${PROJECT_PATH}/qt/${PROJECT_ARCH})
set(Qt3LibPath ${Qt3DirPath}/lib)        
set(Qt3Libs ${Qt3LibPath}/qt-mt338.lib ${Qt3LibPath}/qtmain.lib)   

add_custom_command(TARGET uic.exe
    PRE_BUILD
    COMMAND  ${CMAKE_CURRENT_SOURCE_DIR}/../data/import_card_info.ui -o ${CMAKE_CURRENT_SOURCE_DIR}/../incl/import_card_info_ui.h
    WORKING_DIRECTORY ${Qt3DirPath}/bin
)       

target_link_libraries(${PROJECT_NAME} ${Qt3Libs})

When I run the cmake(click on the configure button on cmake gui), it give me messages

CMake Warning (dev) at src/CMakeLists.txt:21 (add_custom_command):
Policy CMP0040 is not set: The target in the TARGET signature of
add_custom_command() must exist. Run "cmake --help-policy CMP0040" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

The target name "uic.exe" is unknown in this context. This warning is for project developers. Use -Wno-dev to suppress it.

How could I ask the uic.exe generate the ui file for me by cmake?

ps : The find_package command cannot work, that is why I want to write a simple function to generate the ui and moc file for me. I try to setup the CMAKE_PREFIX_PATH, but it also do not work

#set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${Qt3Dir}")

Solution

  • I find out the reason, for cmake to generate a makefile which would call the exe setting by set_custom_target, I have to add a command

    add_dependencies(${PROJECT_NAME} uic)