Skip to content

Commit

Permalink
Initial commits to build qtests from cmake / ctest. Non functional yet
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@6949 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed May 21, 2007
1 parent be639d1 commit c90f2c4
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ SET (BINDINGS_GLOBAL_INSTALL FALSE CACHE BOOL "Install bindings to global python
# Compile flag. Make it posible to turn it off.
SET (PEDANTIC TRUE CACHE BOOL "Determines if we should compile with -Wall -Werror.")

# whether unit tests should be build
SET (ENABLE_TESTS FALSE CACHE BOOL "Build unit tests?")

# hide this variable because building of python bindings might fail
# if set to other directory than expected
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH)
Expand Down Expand Up @@ -102,6 +105,10 @@ SET( QT_USE_QT3SUPPORT TRUE )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTNETWORK TRUE )
SET( QT_USE_QTSVG TRUE )
IF (ENABLE_TESTS)
SET( QT_USE_QTTESTS TRUE )
ENABLE_TESTING()
ENDIF (ENABLE_TESTS)
# TODO: should not be needed, report it to CMake devs
IF (APPLE AND QT_USE_QT3SUPPORT)
SET( QT_USE_QTSQL TRUE )
Expand Down Expand Up @@ -222,6 +229,9 @@ IF (HAVE_PYTHON)
SUBDIRS (python)
ENDIF (HAVE_PYTHON)

IF (ENABLE_TESTS)
SUBDIRS(tests)
ENDIF (ENABLE_TESTS)

#############################################################
# install stuff
Expand Down
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IF (ENABLE_TESTS)
SUBDIRS(src)
ENDIF (ENABLE_TESTS)
3 changes: 3 additions & 0 deletions tests/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
IF (ENABLE_TESTS)
SUBDIRS(core)
ENDIF (ENABLE_TESTS)
76 changes: 76 additions & 0 deletions tests/src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#############################################################
# sources

# application test

SET(applicationtest_SRCS testqgsapplication.cpp)
SET(applicationtest_MOC_CPPS testqgsapplication.cpp)
QT4_WRAP_CPP(applicationtest_MOC_SRCS ${applicationtest_MOC_CPPS})
ADD_CUSTOM_TARGET(applicationtestmoc ALL DEPENDS ${applicationtest_MOC_SRCS})
#QT4_GENERATE_MOC(${CMAKE_CURRENT_SOURCE_DIR}/testqgsapplication.cpp moc_testqgsapplication.cxx)

#####################################################

# Don't forget to include output directory, otherwise
# the UI file won't be wrapped!
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/core
${QT_INCLUDE_DIR}
${GDAL_INCLUDE_DIR}
${PROJ_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}
)

# expect that classes are being IMPORTED for the exe
IF (WIN32)
# expect that classes are being imported
# Note: MSVC doesn't like when the macros are quotes
# and MSYS doesn't like them unqouted (bacause of braces)
IF (MSVC)
ADD_DEFINITIONS("-DCORE_EXPORT=__declspec(dllimport)")
#ADD_DEFINITIONS("-DPLUGIN_EXPORT=__declspec(dllimport)")
#next needed for qgis gui includes
ADD_DEFINITIONS("-DGUI_EXPORT=__declspec(dllexport)")
ELSE (MSVC)
ADD_DEFINITIONS("\"-DCORE_EXPORT=__declspec(dllimport)\"")
#ADD_DEFINITIONS("\"-DPLUGIN_EXPORT=__declspec(dllimport)\"")
#next needed for qgis gui includes
ADD_DEFINITIONS("\"-DGUI_EXPORT=__declspec(dllexport)\"")
ENDIF (MSVC)
ENDIF (WIN32)

#############################################################
# libraries

# because of htonl
IF (WIN32)
SET(PLATFORM_LIBRARIES wsock32)
ENDIF (WIN32)


#note for tests we should not include the moc of our
#qtests as they are directly included in teh sources
#and should not be compiled twice. Trying to include
#them in below will cause an error at build time

ADD_EXECUTABLE(applicationtest
${applicationtest_SRCS}
)
TARGET_LINK_LIBRARIES(applicationtest
${QT_LIBRARIES}
qgis_core
)

# Since the tests are not actually installed, but rather
# run directly from the build/src/tests dir we need to
# ensure the libs can be found.
IF (APPLE)
# For Mac OS X, the executable must be at the root of the bundle's executable folder
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../lib)
INSTALL(TARGETS applicationtest RUNTIME DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
ELSE (APPLE)
INSTALL(TARGETS applicationtest RUNTIME DESTINATION ${OMG_BIN_DIR})
ENDIF (APPLE)

ADD_TEST(application ${CMAKE_CURRENT_BINARY_DIR}/applicationtest)

0 comments on commit c90f2c4

Please sign in to comment.