I have a CMakeLists.txt file that took me a while to get together, which is general to Qt4 and CMake. Only the project name needs to be changed in this CMakeLists.txt file for a Qt only project.
CMakeLists.txt:
cmake_minimum_required (VERSION 2.8)
project (YourOwnProjectNameHere)
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
file(GLOB ${PROJECT_NAME}_SOURCES *.cpp)
file(GLOB ${PROJECT_NAME}_HEADERS *.h)
file(GLOB ${PROJECT_NAME}_FORMS *.ui)
file(GLOB ${PROJECT_NAME}_RESOURCES resources.qrc)
qt4_wrap_cpp(${PROJECT_NAME}_HEADERS_MOC ${${PROJECT_NAME}_HEADERS})
qt4_wrap_ui(${PROJECT_NAME}_FORMS_UIC ${${PROJECT_NAME}_FORMS})
qt4_add_resources(${PROJECT_NAME}_RESOURCES_RCC ${${PROJECT_NAME}_RESOURCES})
source_group("Headers" FILES ${${PROJECT_NAME}_HEADERS})
source_group("Qt4 MetaObjectCompiler Files" FILES ${${PROJECT_NAME}_HEADERS_MOC})
source_group("Qt4 Forms" FILES ${${PROJECT_NAME}_FORMS} ${${PROJECT_NAME}_FORMS_UIC})
source_group("Qt4 Resources" FILES ${${PROJECT_NAME}_RESOURCES_RCC} ${${PROJECT_NAME}_RESOURCES})
#set(QT_USE_QTNETWORK, true)
#set(QT_USE_QTSQL, true)
#set(QT_USE_QTXML, true)
#set...etc go here
add_executable(${PROJECT_NAME} WIN32
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS}
${${PROJECT_NAME}_HEADERS_MOC}
${${PROJECT_NAME}_FORMS_UIC}
${${PROJECT_NAME}_RESOURCES_RCC}
)
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
I'm using Visual Studio, it tidies away files into folders in what I think is the most logical way. Example:
No comments:
Post a Comment