Skip to content

Commit

Permalink
Fix for #7289, add CMake option to enable building with Qt jom (nmake…
Browse files Browse the repository at this point in the history
…) on Windows

- Can now compile using NMake with jom directly from QtCreator using MSVC compiler (2008) and OSGeo4W devel libs
- Make app capable of running from build directory
- Caveat: may be better way to do it; could have better warning control
  • Loading branch information
dakcarto committed Mar 9, 2013
1 parent 4d8e426 commit 28e1715
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
18 changes: 15 additions & 3 deletions CMakeLists.txt
Expand Up @@ -125,6 +125,11 @@ SET (ENABLE_TESTS TRUE CACHE BOOL "Build unit tests?")
# if set to other directory than expected
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH)

IF (MSVC AND CMAKE_GENERATOR MATCHES "NMake")
# following variable is also used in qgsconfig.h
SET (USING_NMAKE TRUE)
ENDIF (MSVC AND CMAKE_GENERATOR MATCHES "NMake")

#############################################################
# check if lexer and parser are not missing
# http://www.mail-archive.com/cmake@cmake.org/msg02861.html
Expand Down Expand Up @@ -295,7 +300,9 @@ FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
IF (PEDANTIC)
MESSAGE (STATUS "Pedantic compiler settings enabled")
IF(MSVC)
ADD_DEFINITIONS( /W4 )
IF (NOT USING_NMAKE)
ADD_DEFINITIONS( /W4 )
ENDIF (NOT USING_NMAKE)

# disable warnings
ADD_DEFINITIONS( /wd4100 ) # unused formal parameters
Expand All @@ -305,6 +312,9 @@ IF (PEDANTIC)
ADD_DEFINITIONS( /wd4512 ) # assignment operator could not be generated (sqlite3_index_info)
ADD_DEFINITIONS( /wd4610 ) # user defined constructor required (sqlite3_index_info)
ADD_DEFINITIONS( /wd4706 ) # assignment within conditional expression (pal)
IF (USING_NMAKE)
ADD_DEFINITIONS( /wd4999 ) # unknown warnings
ENDIF (USING_NMAKE)
ELSE (MSVC)
# add warnings via flags (not as definitions as on Mac -Wall can not be overridden per language )
SET(_warnings "-Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing")
Expand Down Expand Up @@ -372,8 +382,10 @@ IF (WIN32)
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS)

IF (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
MESSAGE (STATUS "Generating browse files")
ADD_DEFINITIONS( /FR )
IF (NOT USING_NMAKE)
MESSAGE (STATUS "Generating browse files")
ADD_DEFINITIONS( /FR )
ENDIF (NOT USING_NMAKE)
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)

IF (INSTALL_DEPS)
Expand Down
2 changes: 2 additions & 0 deletions cmake_templates/qgsconfig.h.in
Expand Up @@ -32,6 +32,8 @@
//used by Mac to find system Qt plugins when bundle is run from build directory
#define QTPLUGINSDIR "${QT_PLUGINS_DIR}"

#cmakedefine USING_NMAKE

#cmakedefine HAVE_POSTGRESQL

#cmakedefine HAVE_SPATIALITE
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsapplication.cpp
Expand Up @@ -118,7 +118,7 @@ void QgsApplication::init( QString customConfigPath )
{
// we run from source directory - not installed to destination (specified prefix)
ABISYM( mPrefixPath ) = QString(); // set invalid path
#ifdef _MSC_VER
#if defined(_MSC_VER) && ! defined(USING_NMAKE)
setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) + "/" + ABISYM( mCfgIntDir ) );
#else
setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
Expand Down
6 changes: 3 additions & 3 deletions src/crssync/CMakeLists.txt
Expand Up @@ -12,17 +12,17 @@ TARGET_LINK_LIBRARIES(crssync
${GDAL_LIBRARY}
)

IF(MSVC)
IF(MSVC AND NOT USING_NMAKE)
ADD_CUSTOM_TARGET(synccrsdb
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/crssync.exe
DEPENDS crssync
)
ELSE(MSVC)
ELSE(MSVC AND NOT USING_NMAKE)
ADD_CUSTOM_TARGET(synccrsdb
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/crssync
DEPENDS crssync
)
ENDIF(MSVC)
ENDIF(MSVC AND NOT USING_NMAKE)

INSTALL(CODE "MESSAGE(\"Installing crssync ...\")")
INSTALL(TARGETS crssync RUNTIME DESTINATION ${QGIS_LIBEXEC_DIR})
12 changes: 8 additions & 4 deletions src/helpviewer/main.cpp
Expand Up @@ -41,14 +41,18 @@ int main( int argc, char ** argv )
{
context = argv[1];
}

if ( !QgsApplication::isRunningFromBuildDir() )
{
#if defined(Q_WS_MACX)
// If we're on Mac, we have the resource library way above us...
a.setPkgDataPath( QgsApplication::prefixPath() + "/../../../../" + QString( QGIS_DATA_SUBDIR ) );
// If we're on Mac, we have the resource library way above us...
a.setPkgDataPath( QgsApplication::prefixPath() + "/../../../../" + QString( QGIS_DATA_SUBDIR ) );
#elif defined(Q_WS_WIN)
a.setPkgDataPath( QgsApplication::prefixPath() + "/" QGIS_DATA_SUBDIR );
a.setPkgDataPath( QgsApplication::prefixPath() + "/" QGIS_DATA_SUBDIR );
#else
a.setPkgDataPath( QgsApplication::prefixPath() + "/../" QGIS_DATA_SUBDIR );
a.setPkgDataPath( QgsApplication::prefixPath() + "/../" QGIS_DATA_SUBDIR );
#endif
}

QString i18nPath = QgsApplication::i18nPath();
if ( myTranslationCode.isEmpty() )
Expand Down

0 comments on commit 28e1715

Please sign in to comment.