Project (OVW)
Cmake_minimum_required (VERSION 2.8)
# turn on show compile cmd line
SET (Cmake_verbose_makefile on)
SET (Cmake_prefix_path "f:/qt5.3.1/win32_static_2013")
# Set Source dir of CPP
SET (Src_dir ${project_source_dir}/.)
SET (Qtlib_dir "f:/qt5.3.1/win32_static_2013")
#to set Compiler flag
if (WIN32)
SET (cmake_cxx_flags "${cmake_cxx_flags}")
Else ()
SET (cmake_cxx_flags "${cmake_cxx_flags}-g-wall-d_os_linux_")
#to link Static
SET (cmake_exe_linker_flags "${cmake_exe_linker_flags}-static")
#SET (cmake_cxx_flags "${cmake_cxx_flags}-o2-wall")
endif ()
#create qtplugin File
SET (plugin_cpp "${cmake_binary_dir}/qt_plugin_moc.cpp")
FILE (WRITE ${plugin_cpp} "#include <qtplugin>\n")
FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qwindowsintegrationplugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (accessiblefactory) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qddsplugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qicnsplugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qicoplugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qjp2plugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qmngplugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qtgaplugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qtiffplugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qwbmpplugin) \ n")
#FILE (APPEND ${plugin_cpp} "Q_import_plugin (Qwebpplugin) \ n")
#Set Output dir
SET (Executable_output_path ${src_dir}/bin)
SET (Library_output_path ${src_dir}/bin)
#Set Include dir
Include_directories (
${src_dir}
# ${src_dir}/controls
# ${src_dir}/rapidxml
)
Set (Cmake_include_current_dir on)
# Instruct CMake to run MOC automatically when needed.
Set (Cmake_automoc on)
Cmake_policy (SET CMP0020 NEW) # No need to SET link to qtmain.lib
Find_package (Qt5widgets REQUIRED)
# The Qt5widgets_includes also includes the Include directories for
# Dependencies Qtcore and Qtgui
Include_directories (${qt5widgets_includes})
# We need add-dqt_widgets_lib when using the Qtwidgets in Qt 5.
Add_definitions (${qt5widgets_definitions})
# executables fail to build with Qt 5 in the default configuration
# Without-fpie. We add that here.
Set (cmake_cxx_flags "${qt5widgets_executable_compile_flags}")
Aux_source_directory (${src_dir} src_list)
#aux_source_directory (${src_dir}/controls control_list)
QT5_WRAP_UI (Ui_files ${src_dir}/mainwindow.ui)
#QT5_ADD_RESOURCES (RESOURCES ${SRC_DIR}/PIC.QRC)
#LINK_DIRECTORIES (${qtlib_dir}/lib)
Link_directories (${qtlib_dir}/plugins/platforms)
Link_directories (${qtlib_dir}/lib)
Link_directories (${qtlib_dir}/plugins/imageformats)
Link_directories (${qtlib_dir}/plugins/accessible)
#add_executable (${project_name} ${src_list} ${control_list} ${resources})
Add_executable (${project_name} WIN32 ${src_list} ${plugin_cpp} ${ui_files})
# Use the Widgets module from Qt 5
Qt5_use_modules (${project_name} Widgets)
Set (qt5_libs ws2_32 opengl32 imm32 winmm qt5platformsupportd qwindowsd qtaccessiblewidgetsd)
Target_link_libraries (${project_name} ${qt5_libs})