@@ -43,6 +43,9 @@ endif()
4343
4444set (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "limited configs" FORCE)
4545
46+ # Qt5
47+ set (CMAKE_INCLUDE_CURRENT_DIR ON ) # Because the ui_mainwindow.h file.
48+
4649# Boost
4750#SET(Boost_DEBUG OFF) #Switch this and next to ON for help debugging Boost problems.
4851#SET(Boost_DETAILED_FAILURE_MSG ON)
@@ -76,40 +79,50 @@ endfunction()
7679# OS X (homebrew) and Conda the libraries are installed
7780# separately to save space, ease upgrading and distribution
7881function (installLSLApp target )
82+ get_target_property (TARGET_LIBRARIES ${target} LINK_LIBRARIES )
83+ string (REGEX MATCH ";Qt5::" qtapp ";${TARGET_LIBRARIES} " )
84+ if (qtapp)
85+ # Enable automatic compilation of .cpp->.moc, xy.ui->ui_xy.h and resource files
86+ set_target_properties (${target} PROPERTIES
87+ AUTOMOC ON
88+ AUTOUIC ON
89+ AUTORCC ON
90+ )
91+ endif ()
7992 if (LSL_UNIXFOLDERS)
8093 install (TARGETS ${target}
8194 COMPONENT "${PROJECT_NAME} "
8295 RUNTIME DESTINATION bin
8396 LIBRARY DESTINATION lib
8497 )
8598 else ()
86- installLSLAppSingleFolder(${target} )
99+ installLSLAppSingleFolder(${target} " ${qtapp} " )
87100 endif ()
88101 set_property (GLOBAL APPEND PROPERTY
89102 "LSLDEPENDS_${PROJECT_NAME} " liblsl)
90103endfunction ()
91104
92- macro (findQtInstallationTool qtdeploytoolname)
93- if (QT_QMAKE_EXE AND EXISTS ${QT_QMAKE_EXE} )
94- message (STATUS "Qt deploy tool found at ${QT_QMAKE_EXE} " )
105+ function (findQtInstallationTool qtdeploytoolname)
106+ if (QT_DEPLOYQT_EXECUTABLE)
95107 return ()
96108 endif ()
97109 get_target_property (QT_QMAKE_EXE Qt5::qmake IMPORTED_LOCATION )
98- execute_process (COMMAND ${QT_QMAKE_EXE} -query QT_VERSION OUTPUT_VARIABLE QT_VERSION)
99110 get_filename_component (QT_BIN_DIR "${QT_QMAKE_EXE} " DIRECTORY )
100111 find_program (QT_DEPLOYQT_EXECUTABLE ${qtdeploytoolname} HINTS "${QT_BIN_DIR} " )
101- if (NOT QT_DEPLOYQT_EXECUTABLE)
112+ if (QT_DEPLOYQT_EXECUTABLE)
113+ message (STATUS "Qt deploy tool found at ${QT_DEPLOYQT_EXECUTABLE} " )
114+ else ()
102115 message (WARNING "Windeployqt wasn't found, installing ${PROJECT_NAME} will fail!" )
103116 return ()
104117 endif ()
105- endmacro ()
118+ endfunction ()
106119
107120# installLSLAppSingleFolder: installs the app its folder and copies needed libraries
108121#
109122# when calling make install / ninja install the executable is installed to
110123# CMAKE_INSTALL_PREFIX/PROJECT_NAME/TARGET_NAME
111124# e.g. C:/LSL/BrainAmpSeries/BrainAmpSeries.exe
112- function (installLSLAppSingleFolder target )
125+ function (installLSLAppSingleFolder target deployqt )
113126 install (TARGETS ${target}
114127 COMPONENT "${PROJECT_NAME} "
115128 BUNDLE DESTINATION ${PROJECT_NAME}
@@ -128,8 +141,7 @@ function(installLSLAppSingleFolder target)
128141 endif ()
129142
130143 # do we need to install with Qt5?
131- get_target_property (TARGET_LIBRARIES ${target} LINK_LIBRARIES )
132- if (";${TARGET_LIBRARIES} " MATCHES ";Qt5::" )
144+ if (deployqt)
133145 if (WIN32 )
134146 findQtInstallationTool("windeployqt" )
135147 if (QT_DEPLOYQT_EXECUTABLE)
@@ -165,7 +177,7 @@ function(installLSLAppSingleFolder target)
165177 list(GET _files 1 _dest)
166178 execute_process(
167179 COMMAND \" ${CMAKE_COMMAND} \" -E
168- copy \$ {_src} \"\$ {CMAKE_INSTALL_PREFIX}/${PROJECT_NAME} /$\{ _dest}\"
180+ copy_if_different \$ {_src} \"\$ {CMAKE_INSTALL_PREFIX}/${PROJECT_NAME} /$\{ _dest}\"
169181 )
170182 list(REMOVE_AT _files 0 1)
171183 endwhile()
@@ -266,9 +278,9 @@ if(WIN32 AND MSVC)
266278 message (STATUS "Found Qt directories: ${Qt5ConfGlobbed} " )
267279 list (SORT Qt5ConfGlobbed)
268280 list (GET Qt5ConfGlobbed -1 Qt5_DIR)
269- message ( STATUS "You didn't specify a Qt5_DIR. I'm guessing it's ${Qt5_DIR} . " )
281+ set ( Qt5_DIR ${Qt5_DIR} CACHE PATH "Qt5 dir " )
270282 endif ()
271- message (STATUS "If you are building Apps that require Qt, please add the correct dir:" )
283+ message (STATUS "If this is wrong and you are building Apps that require Qt, please add the correct dir:" )
272284 message (STATUS " -DQt5_DIR=/path/to/Qt5/5.x.y/msvc_${VCYEAR} _${lslplatform} /lib/cmake/Qt5" )
273285 endif ()
274286
0 commit comments