diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a994624..6691be4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,14 +43,18 @@ IF(WIN32) ENDIF() # Qt is required for building the tests, the example and optionally for bundling the documentation -find_package(Qt5Test 5.2) -find_package(Qt5OpenGL 5.2) +FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL QtTest) +INCLUDE(${QT_USE_FILE}) +if(CMAKE_VERSION VERSION_LESS "2.8.6") + set_package_info(Doxygen "API documentation generator" http://www.doxygen.org "Building the API documentation") + set_package_info(Qt4 "C++ framework" http://qt-project.org "Building the examples and tests") +else() + set_package_properties(Doxygen PROPERTIES URL http://www.doxygen.org DESCRIPTION "API documentation generator" TYPE OPTIONAL PURPOSE "Building the API documentation") + set_package_properties(Qt4 PROPERTIES DESCRIPTION "C++ framework" URL http://qt-project.org) + set_package_properties(Qt4 PROPERTIES TYPE RECOMMENDED PURPOSE "Building the examples") + set_package_properties(Qt4 PROPERTIES TYPE OPTIONAL PURPOSE "Building the tests") +endif() -set_package_properties(Doxygen PROPERTIES URL http://www.doxygen.org DESCRIPTION "API documentation generator" TYPE OPTIONAL PURPOSE "Building the API documentation") -set_package_properties(Qt5Test PROPERTIES DESCRIPTION "C++ framework" URL http://qt-project.org) -set_package_properties(Qt5Test PROPERTIES TYPE OPTIONAL PURPOSE "Building the tests") -set_package_properties(Qt5OpenGL PROPERTIES DESCRIPTION "C++ framework" URL http://qt-project.org) -set_package_properties(Qt5OpenGL PROPERTIES TYPE RECOMMENDED PURPOSE "Building the examples") IF(CMAKE_COMPILER_IS_GNUCXX) #Maybe "OR MINGW" ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode @@ -62,7 +66,7 @@ endif() ADD_SUBDIRECTORY(library) OPTION(ENABLE_EXAMPLES "Should the examples be built" ON) -IF(ENABLE_EXAMPLES AND Qt5OpenGL_FOUND) +IF(ENABLE_EXAMPLES AND QT_QTOPENGL_FOUND) ADD_SUBDIRECTORY(examples/common) ADD_SUBDIRECTORY(examples/Basic) ADD_SUBDIRECTORY(examples/Paging) @@ -77,7 +81,7 @@ ENDIF() INCLUDE(Packaging.cmake) OPTION(ENABLE_TESTS "Should the tests be built" ON) -IF(ENABLE_TESTS AND Qt5Test_FOUND) +IF(ENABLE_TESTS AND QT_QTTEST_FOUND) INCLUDE(CTest) MARK_AS_ADVANCED(FORCE BUILD_TESTING) ADD_SUBDIRECTORY(tests) diff --git a/examples/Basic/CMakeLists.txt b/examples/Basic/CMakeLists.txt index a7b81ff5..02e203d2 100644 --- a/examples/Basic/CMakeLists.txt +++ b/examples/Basic/CMakeLists.txt @@ -19,6 +19,8 @@ # 3. This notice may not be removed or altered from any source # distribution. +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + PROJECT(BasicExample) #Projects source files @@ -42,7 +44,7 @@ SOURCE_GROUP("Headers" FILES ${INC_FILES}) FIND_PACKAGE(OpenGL REQUIRED) #Tell CMake the paths for OpenGL and for PolyVox (which is just relative to our current location) -INCLUDE_DIRECTORIES(${PolyVoxCore_BINARY_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${PolyVoxCore_BINARY_DIR}/include ${PolyVoxCore_SOURCE_DIR}/include ${GLEW_SOURCE_DIR}) LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR}) #Build @@ -50,7 +52,7 @@ ADD_EXECUTABLE(BasicExample ${SRC_FILES}) IF(MSVC) SET_TARGET_PROPERTIES(BasicExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") ENDIF(MSVC) -TARGET_LINK_LIBRARIES(BasicExample glew Qt5::OpenGL ${OPENGL_gl_LIBRARY} PolyVoxCore) +TARGET_LINK_LIBRARIES(BasicExample glew ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) SET_PROPERTY(TARGET BasicExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/examples/Basic/OpenGLWidget.cpp b/examples/Basic/OpenGLWidget.cpp index 5b93b08e..9b662fb2 100644 --- a/examples/Basic/OpenGLWidget.cpp +++ b/examples/Basic/OpenGLWidget.cpp @@ -2,7 +2,7 @@ #include #include -#include +//#include using namespace PolyVox; using namespace std; @@ -73,7 +73,7 @@ void OpenGLWidget::initializeGL() glDepthFunc(GL_LEQUAL); glDepthRange(0.0, 1.0); - if(!shader.addShaderFromSourceCode(QOpenGLShader::Vertex, R"( + if (!shader.addShaderFromSourceCode(QGLShader::Vertex, R"( #version 140 in vec4 position; //This will be the position of the vertex in model-space @@ -96,7 +96,7 @@ void OpenGLWidget::initializeGL() exit(EXIT_FAILURE); } - if(!shader.addShaderFromSourceCode(QOpenGLShader::Fragment, R"( + if (!shader.addShaderFromSourceCode(QGLShader::Fragment, R"( #version 130 in vec4 worldPosition; //Passed in from the vertex shader diff --git a/examples/Basic/OpenGLWidget.h b/examples/Basic/OpenGLWidget.h index 1b201803..1126aba3 100644 --- a/examples/Basic/OpenGLWidget.h +++ b/examples/Basic/OpenGLWidget.h @@ -29,7 +29,7 @@ distribution. #include "glew/glew.h" #include -#include +#include class OpenGLWidget : public QGLWidget { @@ -57,7 +57,7 @@ private: GLuint vertexBuffer; GLuint vertexArrayObject; - QOpenGLShaderProgram shader; + QGLShaderProgram shader; //Mouse data QPoint m_LastFrameMousePos; diff --git a/examples/OpenGL/CMakeLists.txt b/examples/OpenGL/CMakeLists.txt index 32709e81..5cd1ed55 100644 --- a/examples/OpenGL/CMakeLists.txt +++ b/examples/OpenGL/CMakeLists.txt @@ -60,7 +60,7 @@ ADD_EXECUTABLE(OpenGLExample ${SRC_FILES}) IF(MSVC) SET_TARGET_PROPERTIES(OpenGLExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") ENDIF(MSVC) -TARGET_LINK_LIBRARIES(OpenGLExample glew Qt5::OpenGL ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) +TARGET_LINK_LIBRARIES(OpenGLExample glew ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) SET_PROPERTY(TARGET OpenGLExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/examples/Paging/CMakeLists.txt b/examples/Paging/CMakeLists.txt index 97cec53a..e8020b2d 100644 --- a/examples/Paging/CMakeLists.txt +++ b/examples/Paging/CMakeLists.txt @@ -19,6 +19,8 @@ # 3. This notice may not be removed or altered from any source # distribution. +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + PROJECT(PagingExample) #Projects source files @@ -52,7 +54,7 @@ ADD_EXECUTABLE(PagingExample ${SRC_FILES}) IF(MSVC) SET_TARGET_PROPERTIES(PagingExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") ENDIF(MSVC) -TARGET_LINK_LIBRARIES(PagingExample glew Qt5::OpenGL ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) +TARGET_LINK_LIBRARIES(PagingExample glew ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) SET_PROPERTY(TARGET PagingExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/examples/SmoothLOD/CMakeLists.txt b/examples/SmoothLOD/CMakeLists.txt index 9c5649fc..570cda55 100644 --- a/examples/SmoothLOD/CMakeLists.txt +++ b/examples/SmoothLOD/CMakeLists.txt @@ -19,6 +19,8 @@ # 3. This notice may not be removed or altered from any source # distribution. +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + PROJECT(SmoothLODExample) #Projects source files @@ -50,7 +52,7 @@ ADD_EXECUTABLE(SmoothLODExample ${SRC_FILES}) IF(MSVC) SET_TARGET_PROPERTIES(SmoothLODExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") #All warnings ENDIF(MSVC) -TARGET_LINK_LIBRARIES(SmoothLODExample glew Qt5::OpenGL ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) +TARGET_LINK_LIBRARIES(SmoothLODExample glew ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore) SET_PROPERTY(TARGET SmoothLODExample PROPERTY FOLDER "Examples") #Install - Only install the example in Windows diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6b06437b..fbffe9d9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,14 +24,12 @@ # # Also sets LATEST_TEST to point to the output executable of the test for easy # ADD_TEST()ing - -set(CMAKE_AUTOMOC TRUE) - -MACRO(CREATE_TEST sourcefile executablename) +MACRO(CREATE_TEST headerfile sourcefile executablename) UNSET(test_moc_SRCS) #clear out the MOCs from previous tests + QT4_WRAP_CPP(test_moc_SRCS ${headerfile}) LINK_DIRECTORIES(${PolyVoxCore_BINARY_DIR} ${PolyVoxUtil_BINARY_DIR}) ADD_EXECUTABLE(${executablename} ${sourcefile} ${test_moc_SRCS}) - TARGET_LINK_LIBRARIES(${executablename} PolyVoxCore PolyVoxUtil Qt5::Test) + TARGET_LINK_LIBRARIES(${executablename} PolyVoxCore PolyVoxUtil ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY}) #HACK. This is needed since everything is built in the base dir in Windows. As of 2.8 we should change this. IF(WIN32) SET(LATEST_TEST ${EXECUTABLE_OUTPUT_PATH}/${executablename}) @@ -48,17 +46,22 @@ MACRO(CREATE_TEST sourcefile executablename) ENDMACRO(CREATE_TEST) INCLUDE_DIRECTORIES(${PolyVoxCore_BINARY_DIR}/include ${PolyVox_SOURCE_DIR}/PolyVoxCore/include ${CMAKE_CURRENT_BINARY_DIR}) +REMOVE_DEFINITIONS(-DQT_GUI_LIB) #Make sure the tests don't link to the QtGui # Test Template. Copy and paste this template for consistant naming. # # ClassName tests -# CREATE_TEST(TestClassName.cpp TestClassName) +# CREATE_TEST(TestClassName.h TestClassName.cpp TestClassName) # ADD_TEST(ClassNameFeature1Test ${LATEST_TEST} testFeature1) # ADD_TEST(ClassNameFeature2Test ${LATEST_TEST} testFeature2) # Python tests IF(BUILD_BINDINGS) FIND_PACKAGE(PythonInterp 3) - set_package_properties(PythonInterp PROPERTIES URL http://www.python.org DESCRIPTION "Python Interpereter" TYPE OPTIONAL PURPOSE "Running the Python tests") + IF(CMAKE_VERSION VERSION_LESS "2.8.6") + set_package_info(PythonInterp "Python Interpereter" http://www.python.org "Running the Python tests") + ELSE() + set_package_properties(PythonInterp PROPERTIES URL http://www.python.org DESCRIPTION "Python Interpereter" TYPE OPTIONAL PURPOSE "Running the Python tests") + ENDIF() IF(PYTHONINTERP_FOUND) ADD_TEST(PythonSurfaceExtractorTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/TestSurfaceExtractor.py) ADD_TEST(PythonRaycastTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/TestRaycast.py) @@ -66,38 +69,38 @@ IF(BUILD_BINDINGS) ENDIF() # AmbientOcclusionGenerator tests -CREATE_TEST(TestAmbientOcclusionGenerator.cpp TestAmbientOcclusionGenerator) +CREATE_TEST(TestAmbientOcclusionGenerator.h TestAmbientOcclusionGenerator.cpp TestAmbientOcclusionGenerator) # Array tests -CREATE_TEST(TestArray.cpp TestArray) +CREATE_TEST(TestArray.h TestArray.cpp TestArray) # AStarPathfinder tests -CREATE_TEST(TestAStarPathfinder.cpp TestAStarPathfinder) +CREATE_TEST(TestAStarPathfinder.h TestAStarPathfinder.cpp TestAStarPathfinder) -CREATE_TEST(TestCubicSurfaceExtractor.cpp TestCubicSurfaceExtractor) +CREATE_TEST(TestCubicSurfaceExtractor.h TestCubicSurfaceExtractor.cpp TestCubicSurfaceExtractor) # Low pass filter tests -CREATE_TEST(TestLowPassFilter.cpp TestLowPassFilter) +CREATE_TEST(TestLowPassFilter.h TestLowPassFilter.cpp TestLowPassFilter) # Material tests -CREATE_TEST(testmaterial.cpp testmaterial) +CREATE_TEST(testmaterial.h testmaterial.cpp testmaterial) # Raycast tests -CREATE_TEST(TestRaycast.cpp TestRaycast) +CREATE_TEST(TestRaycast.h TestRaycast.cpp TestRaycast) # Picking tests -CREATE_TEST(TestPicking.cpp TestPicking) +CREATE_TEST(TestPicking.h TestPicking.cpp TestPicking) # Region tests -CREATE_TEST(TestRegion.cpp TestRegion) +CREATE_TEST(TestRegion.h TestRegion.cpp TestRegion) -CREATE_TEST(TestSurfaceExtractor.cpp TestSurfaceExtractor) +CREATE_TEST(TestSurfaceExtractor.h TestSurfaceExtractor.cpp TestSurfaceExtractor) #Vector tests -CREATE_TEST(testvector.cpp testvector) +CREATE_TEST(testvector.h testvector.cpp testvector) # Volume tests -CREATE_TEST(testvolume.cpp testvolume) +CREATE_TEST(testvolume.h testvolume.cpp testvolume) # Volume subclass tests -CREATE_TEST(TestVolumeSubclass.cpp TestVolumeSubclass) +CREATE_TEST(TestVolumeSubclass.h TestVolumeSubclass.cpp TestVolumeSubclass)