http://programmingexamples.net/w/index.php?title=Building_on_Windows&feed=atom&action=history
Building on Windows - Revision history
2024-03-28T14:14:24Z
Revision history for this page on the wiki
MediaWiki 1.23.5
http://programmingexamples.net/w/index.php?title=Building_on_Windows&diff=5196&oldid=prev
Daviddoria at 17:56, 16 September 2012
2012-09-16T17:56:43Z
<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 17:56, 16 September 2012</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 37:</td>
<td colspan="2" class="diff-lineno">Line 37:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>set_target_properties(FileMenu PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>set_target_properties(FileMenu PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></source></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">If you want to set this for all build modes, simply use:</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"><source lang="cmake"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">set_target_properties(FileMenu PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") # works for all build modes</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></source></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></source></div></td></tr>
</table>
Daviddoria
http://programmingexamples.net/w/index.php?title=Building_on_Windows&diff=5195&oldid=prev
Daviddoria: Created page with 'A typical CMakeLists.txt file on this site looks like this: <source lang="cmake"> cmake_minimum_required(VERSION 2.6) PROJECT(FileMenu) FIND_PACKAGE(Qt4 REQUIRED) INCLUDE(${QT_…'
2012-09-16T17:42:53Z
<p>Created page with 'A typical CMakeLists.txt file on this site looks like this: <source lang="cmake"> cmake_minimum_required(VERSION 2.6) PROJECT(FileMenu) FIND_PACKAGE(Qt4 REQUIRED) INCLUDE(${QT_…'</p>
<p><b>New page</b></p><div>A typical CMakeLists.txt file on this site looks like this:<br />
<br />
<source lang="cmake"><br />
cmake_minimum_required(VERSION 2.6)<br />
PROJECT(FileMenu)<br />
<br />
FIND_PACKAGE(Qt4 REQUIRED)<br />
INCLUDE(${QT_USE_FILE})<br />
<br />
QT4_WRAP_UI(UISrcs main.ui)<br />
QT4_WRAP_CPP(MOCSrcs filemenu.h)<br />
<br />
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})<br />
<br />
ADD_EXECUTABLE(FileMenu main.cpp filemenu.h filemenu.cpp ${MOCSrcs} ${UISrcs})<br />
TARGET_LINK_LIBRARIES(FileMenu ${QT_LIBRARIES})<br />
</source><br />
<br />
However, when you build and run in Windows, you will get a console window that appears along with your GUI program. To fix this, you must do two things. First, add ${QT_QTMAIN_LIBRARY} to your target_link_libraries command. Second, you must specify /SUBSYSTEM:WINDOWS for all build configurations (Release, Debug, etc) that you want to not pop up the console window. An example is below, where when built in release mode, no console will appear:<br />
<br />
<source lang="cmake"><br />
cmake_minimum_required(VERSION 2.6)<br />
<br />
PROJECT(FileMenu)<br />
<br />
FIND_PACKAGE(Qt4 REQUIRED)<br />
INCLUDE(${QT_USE_FILE})<br />
<br />
QT4_WRAP_UI(UISrcs main.ui)<br />
QT4_WRAP_CPP(MOCSrcs filemenu.h)<br />
<br />
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})<br />
<br />
ADD_EXECUTABLE(FileMenu main.cpp filemenu.h filemenu.cpp ${MOCSrcs} ${UISrcs})<br />
TARGET_LINK_LIBRARIES(FileMenu ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})<br />
<br />
set_target_properties(FileMenu PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")<br />
<br />
</source></div>
Daviddoria