Skip to content
Permalink
Browse files
Fix for #7289, add CMake option to enable building with Qt jom (nmake…
…) 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 28e17159d1c6c7af68783c6596aadf0f77c426b8
Showing with 29 additions and 11 deletions.
  1. +15 −3 CMakeLists.txt
  2. +2 −0 cmake_templates/qgsconfig.h.in
  3. +1 −1 src/core/qgsapplication.cpp
  4. +3 −3 src/crssync/CMakeLists.txt
  5. +8 −4 src/helpviewer/main.cpp
@@ -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
@@ -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
@@ -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")
@@ -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)
@@ -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
@@ -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 ) );
@@ -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})
@@ -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() )

0 comments on commit 28e1715

Please sign in to comment.