2010-07-07 02:54:16 +04:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(tests)
|
|
|
|
|
2010-11-08 07:26:39 +03:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
|
|
|
|
|
2010-11-03 21:26:42 +03:00
|
|
|
# Build debug build as default
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
|
|
|
endif()
|
|
|
|
|
2010-08-31 01:57:11 +04:00
|
|
|
#
|
|
|
|
# Build test apps
|
|
|
|
#
|
|
|
|
|
2011-07-31 05:12:27 +04:00
|
|
|
# Mac OS X
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
|
|
|
|
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
|
2010-08-31 01:57:11 +04:00
|
|
|
# Qt4
|
|
|
|
find_package(OpenGL)
|
|
|
|
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
|
|
|
|
include(${QT_USE_FILE})
|
|
|
|
|
|
|
|
# Eigen2
|
2010-08-31 02:49:24 +04:00
|
|
|
if (NOT EIGEN2_INCLUDE_DIR)
|
|
|
|
find_path(EIGEN2_INCLUDE_DIR
|
|
|
|
Eigen/Core
|
|
|
|
PATHS ENV EIGEN2DIR /opt/local/include/eigen2 /usr/include/eigen2)
|
|
|
|
if (NOT EIGEN2_INCLUDE_DIR)
|
|
|
|
message(FATAL_ERROR "Eigen2 not found")
|
|
|
|
else()
|
|
|
|
message(STATUS "Eigen2 found in " ${EIGEN2_INCLUDE_DIR})
|
|
|
|
endif()
|
2010-08-31 01:57:11 +04:00
|
|
|
endif()
|
2010-08-31 02:49:24 +04:00
|
|
|
include_directories(${EIGEN2_INCLUDE_DIR})
|
2010-08-31 01:57:11 +04:00
|
|
|
|
2010-11-08 07:26:39 +03:00
|
|
|
# OpenCSG
|
2011-08-02 03:43:29 +04:00
|
|
|
if (NOT $ENV{OPENCSG_DIR} STREQUAL "")
|
|
|
|
set(OPENCSG_DIR "$ENV{OPENCSG_DIR}")
|
|
|
|
elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "")
|
2010-11-08 07:26:39 +03:00
|
|
|
set(OPENCSG_DIR "$ENV{MACOSX_DEPLOY_DIR}")
|
|
|
|
endif()
|
|
|
|
if (NOT OPENCSG_INCLUDE_DIR)
|
2011-08-02 03:43:29 +04:00
|
|
|
message(STATUS ${OPENCSG_DIR})
|
2010-11-08 07:26:39 +03:00
|
|
|
find_path(OPENCSG_INCLUDE_DIR
|
|
|
|
opencsg.h
|
2011-08-02 03:43:29 +04:00
|
|
|
PATHS ${OPENCSG_DIR}/include)
|
2010-11-08 07:26:39 +03:00
|
|
|
find_library(OPENCSG_LIBRARY
|
|
|
|
opencsg
|
2011-08-03 01:47:52 +04:00
|
|
|
PATHS ${OPENCSG_DIR}/lib)
|
2010-11-08 07:26:39 +03:00
|
|
|
if (NOT OPENCSG_INCLUDE_DIR OR NOT OPENCSG_LIBRARY)
|
|
|
|
message(FATAL_ERROR "OpenCSG not found")
|
|
|
|
else()
|
|
|
|
message(STATUS "OpenCSG found in " ${OPENCSG_LIBRARY})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
include_directories(${OPENCSG_INCLUDE_DIR})
|
|
|
|
|
2010-11-17 09:26:39 +03:00
|
|
|
if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "")
|
|
|
|
set(GLEW_DIR "$ENV{MACOSX_DEPLOY_DIR}")
|
|
|
|
endif()
|
2010-11-08 07:26:39 +03:00
|
|
|
find_package(GLEW REQUIRED)
|
|
|
|
include_directories(${GLEW_INCLUDE_PATH})
|
|
|
|
|
2010-08-31 01:57:11 +04:00
|
|
|
# Flex/Bison
|
|
|
|
find_package(BISON)
|
|
|
|
find_package(FLEX)
|
|
|
|
# The COMPILE_FLAGS and forced C++ compiler is just to be compatible with qmake
|
|
|
|
FLEX_TARGET(OpenSCADlexer ../src/lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp COMPILE_FLAGS "-Plexer")
|
|
|
|
BISON_TARGET(OpenSCADparser ../src/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser_yacc.c COMPILE_FLAGS "-p parser")
|
|
|
|
ADD_FLEX_BISON_DEPENDENCY(OpenSCADlexer OpenSCADparser)
|
|
|
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/parser_yacc.c PROPERTIES LANGUAGE "CXX")
|
|
|
|
|
|
|
|
|
|
|
|
# Internal includes
|
|
|
|
include_directories(../src)
|
|
|
|
|
|
|
|
add_definitions(-DOPENSCAD_VERSION=test)
|
|
|
|
|
2010-08-31 02:49:24 +04:00
|
|
|
set(COMMON_SOURCES
|
2011-09-04 02:03:16 +04:00
|
|
|
../src/handle_dep.cc
|
|
|
|
../src/qhash.cc
|
2010-08-31 02:49:24 +04:00
|
|
|
../src/export.cc
|
|
|
|
../src/value.cc
|
|
|
|
../src/expr.cc
|
|
|
|
../src/func.cc
|
|
|
|
../src/module.cc
|
|
|
|
../src/node.cc
|
|
|
|
../src/context.cc
|
|
|
|
../src/csgterm.cc
|
|
|
|
../src/polyset.cc
|
|
|
|
../src/csgops.cc
|
|
|
|
../src/transform.cc
|
2011-09-03 01:54:41 +04:00
|
|
|
../src/color.cc
|
2010-08-31 02:49:24 +04:00
|
|
|
../src/primitives.cc
|
|
|
|
../src/projection.cc
|
|
|
|
../src/cgaladv.cc
|
|
|
|
../src/surface.cc
|
|
|
|
../src/control.cc
|
|
|
|
../src/render.cc
|
|
|
|
../src/import.cc
|
|
|
|
../src/dxfdata.cc
|
|
|
|
../src/dxftess.cc
|
|
|
|
../src/dxfdim.cc
|
|
|
|
../src/dxflinextrude.cc
|
|
|
|
../src/dxfrotextrude.cc
|
|
|
|
../src/printutils.cc
|
|
|
|
../src/progress.cc
|
|
|
|
../src/nodedumper.cc
|
|
|
|
../src/traverser.cc
|
2011-07-31 05:12:27 +04:00
|
|
|
../src/PolySetEvaluator.cc
|
2011-09-11 11:10:31 +04:00
|
|
|
../src/PolySetCache.cc
|
2010-08-31 02:49:24 +04:00
|
|
|
../src/Tree.cc
|
|
|
|
${FLEX_OpenSCADlexer_OUTPUTS}
|
|
|
|
${BISON_OpenSCADparser_OUTPUTS})
|
2010-08-31 01:57:11 +04:00
|
|
|
|
2010-11-17 09:26:39 +03:00
|
|
|
#
|
|
|
|
# dumptest
|
|
|
|
#
|
2010-08-31 02:49:24 +04:00
|
|
|
add_executable(dumptest dumptest.cc ${COMMON_SOURCES})
|
2010-08-31 01:57:11 +04:00
|
|
|
target_link_libraries(dumptest ${QT_LIBRARIES} ${OPENGL_LIBRARY})
|
2010-11-17 09:26:39 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# csgtexttest
|
|
|
|
#
|
2010-08-31 02:49:24 +04:00
|
|
|
add_executable(csgtexttest csgtexttest.cc CSGTextRenderer.cc CSGTextCache.cc ../src/qhash.cc ${COMMON_SOURCES})
|
|
|
|
target_link_libraries(csgtexttest ${QT_LIBRARIES} ${OPENGL_LIBRARY})
|
2010-11-17 09:26:39 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# csgtermtest
|
|
|
|
#
|
2011-07-31 05:12:27 +04:00
|
|
|
add_executable(csgtermtest csgtermtest.cc ../src/CSGTermEvaluator.cc ${COMMON_SOURCES})
|
2010-08-31 02:49:24 +04:00
|
|
|
target_link_libraries(csgtermtest ${QT_LIBRARIES} ${OPENGL_LIBRARY})
|
|
|
|
|
2010-09-07 04:05:08 +04:00
|
|
|
if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "")
|
|
|
|
set(CGAL_DIR "$ENV{MACOSX_DEPLOY_DIR}/lib/CGAL")
|
|
|
|
set(CMAKE_MODULE_PATH "${CGAL_DIR}")
|
|
|
|
endif()
|
|
|
|
find_package(CGAL REQUIRED)
|
|
|
|
include_directories(${CGAL_INCLUDE_DIRS})
|
2010-11-17 09:26:39 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# cgaltest
|
|
|
|
#
|
2011-09-08 00:04:59 +04:00
|
|
|
add_executable(cgaltest cgaltest.cc ../src/CGAL_Nef_polyhedron.cc ../src/cgalutils.cc ../src/CSGTermEvaluator.cc
|
2011-09-11 12:51:55 +04:00
|
|
|
../src/CGALEvaluator.cc ../src/CGALCache.cc ../src/PolySetCGALEvaluator.cc ../src/qhash.cc
|
2011-09-07 00:01:42 +04:00
|
|
|
../src/CGAL_Nef_polyhedron_DxfData.cc ../src/cgaladv_minkowski2.cc ../src/cgaladv_convexhull2.cc
|
2011-09-01 06:09:06 +04:00
|
|
|
${COMMON_SOURCES})
|
2010-09-07 04:05:08 +04:00
|
|
|
set_target_properties(cgaltest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
|
|
|
|
target_link_libraries(cgaltest ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${OPENGL_LIBRARY})
|
2010-08-31 01:57:11 +04:00
|
|
|
|
2011-09-01 07:04:42 +04:00
|
|
|
#
|
|
|
|
# cgalpngtest
|
|
|
|
#
|
|
|
|
add_executable(cgalpngtest cgalpngtest.cc OffscreenView.cc OffscreenContext.mm
|
2011-09-08 00:04:59 +04:00
|
|
|
../src/CGALRenderer.cc ../src/CGAL_Nef_polyhedron.cc ../src/cgalutils.cc
|
2011-09-11 12:51:55 +04:00
|
|
|
../src/CSGTermEvaluator.cc ../src/CGALEvaluator.cc ../src/CGALCache.cc
|
2011-09-01 07:04:42 +04:00
|
|
|
../src/PolySetCGALEvaluator.cc ../src/qhash.cc
|
2011-09-07 00:01:42 +04:00
|
|
|
../src/CGAL_Nef_polyhedron_DxfData.cc ../src/cgaladv_minkowski2.cc ../src/cgaladv_convexhull2.cc
|
2011-09-01 07:04:42 +04:00
|
|
|
${COMMON_SOURCES})
|
|
|
|
set_target_properties(cgalpngtest PROPERTIES COMPILE_FLAGS "-DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
|
|
|
|
target_link_libraries(cgalpngtest ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY})
|
|
|
|
|
2010-11-17 09:26:39 +03:00
|
|
|
#
|
|
|
|
# opencsgtest
|
|
|
|
#
|
2011-07-31 05:12:27 +04:00
|
|
|
add_executable(opencsgtest opencsgtest.cc OffscreenView.cc OffscreenContext.mm
|
2011-09-01 06:09:06 +04:00
|
|
|
../src/OpenCSGRenderer.cc ../src/ThrownTogetherRenderer.cc
|
2011-09-08 00:04:59 +04:00
|
|
|
../src/CSGTermEvaluator.cc ../src/CGAL_Nef_polyhedron.cc ../src/cgalutils.cc
|
2011-09-11 12:51:55 +04:00
|
|
|
../src/CGALEvaluator.cc ../src/CGALCache.cc ../src/PolySetCGALEvaluator.cc ../src/qhash.cc
|
2011-09-07 00:01:42 +04:00
|
|
|
../src/CGAL_Nef_polyhedron_DxfData.cc ../src/cgaladv_minkowski2.cc ../src/cgaladv_convexhull2.cc
|
2010-11-08 07:26:39 +03:00
|
|
|
${COMMON_SOURCES})
|
|
|
|
set_target_properties(opencsgtest PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}")
|
2011-07-31 05:12:27 +04:00
|
|
|
target_link_libraries(opencsgtest ${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES} ${QT_LIBRARIES} ${OPENCSG_LIBRARY} ${GLEW_LIBRARY} ${COCOA_LIBRARY} ${OPENGL_LIBRARY})
|
2010-11-08 07:26:39 +03:00
|
|
|
|
2010-07-11 23:06:43 +04:00
|
|
|
#
|
2010-09-07 04:05:08 +04:00
|
|
|
# This functions adds cmd-line tests given files.
|
|
|
|
# Files are sent as the parameters following TESTSUFFIX
|
2010-07-11 23:06:43 +04:00
|
|
|
#
|
2010-09-07 04:05:08 +04:00
|
|
|
function(add_cmdline_test TESTCMD TESTSUFFIX)
|
2010-07-11 23:06:43 +04:00
|
|
|
get_filename_component(TESTCMD_NAME ${TESTCMD} NAME_WE)
|
2010-09-07 04:05:08 +04:00
|
|
|
foreach (SCADFILE ${ARGN})
|
2010-07-11 23:06:43 +04:00
|
|
|
get_filename_component(TESTNAME ${SCADFILE} NAME_WE)
|
2011-04-29 19:07:10 +04:00
|
|
|
string(REPLACE " " "_" TESTNAME ${TESTNAME}) # Test names cannot include spaces
|
|
|
|
add_test("${TESTCMD_NAME}_${TESTNAME}" ${tests_SOURCE_DIR}/test_cmdline_tool.py -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} "${SCADFILE}")
|
2010-07-11 23:06:43 +04:00
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2010-07-07 02:54:16 +04:00
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
# Find all scad files
|
2011-07-11 03:33:17 +04:00
|
|
|
file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad)
|
|
|
|
file(GLOB FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/*.scad)
|
|
|
|
file(GLOB BUGS_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/*.scad)
|
2010-07-07 02:54:16 +04:00
|
|
|
|
|
|
|
# Add dumptest tests to CTest
|
2011-07-11 03:33:17 +04:00
|
|
|
add_cmdline_test(dumptest txt ${MINIMAL_FILES})
|
2010-07-07 03:44:58 +04:00
|
|
|
# Add csgtexttest tests to CTest
|
2011-08-04 20:26:25 +04:00
|
|
|
add_cmdline_test(csgtexttest txt ${MINIMAL_FILES})
|
2010-08-31 02:49:24 +04:00
|
|
|
# Add csgtermtest tests to CTest
|
2011-08-04 20:26:25 +04:00
|
|
|
add_cmdline_test(csgtermtest txt ${MINIMAL_FILES})
|
|
|
|
|
2010-07-09 02:46:19 +04:00
|
|
|
# Add cgaltest tests to CTest
|
2011-09-01 07:04:42 +04:00
|
|
|
add_cmdline_test(cgaltest stl ${CGALTEST_FILES})
|
|
|
|
|
|
|
|
# Add cgalpngtest tests to CTest
|
2011-09-02 04:48:22 +04:00
|
|
|
LIST(APPEND CGALPNGTEST_FILES
|
2011-09-06 16:56:04 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/2d-3d.scad
|
2011-09-02 04:48:22 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/circle-tests.scad
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/square-tests.scad
|
2011-09-04 00:42:48 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/polygon-tests.scad
|
2011-09-02 04:48:22 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/cube-tests.scad
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/sphere-tests.scad
|
2011-09-02 16:31:56 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/cylinder-tests.scad
|
2011-09-02 16:38:27 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/union-tests.scad
|
2011-09-02 16:46:45 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/difference-tests.scad
|
2011-09-03 01:33:18 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/intersection-tests.scad
|
2011-09-05 19:03:39 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/linear_extrude-tests.scad
|
2011-09-05 19:15:56 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/rotate_extrude-tests.scad
|
2011-09-06 16:56:04 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/minkowski2-tests.scad
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/minkowski3-tests.scad
|
2011-09-07 00:01:42 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/hull2-tests.scad
|
2011-09-05 20:00:20 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/surface-tests.scad
|
2011-09-04 00:42:48 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/import_dxf-tests.scad
|
2011-09-05 20:20:43 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/transform-tests.scad
|
2011-09-04 20:25:17 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/color-tests.scad
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/background-modifier.scad
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/highlight-modifier.scad
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/root-modifier.scad
|
2011-09-05 02:04:12 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/disable-modifier.scad
|
2011-09-05 18:38:50 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/for-tests.scad
|
2011-09-05 19:55:17 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/for-nested-tests.scad
|
2011-09-06 20:28:01 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/intersection_for-tests.scad
|
2011-09-06 22:36:45 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/render-tests.scad
|
2011-09-08 00:56:39 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/projection-tests.scad
|
2011-09-08 04:31:47 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/assign-tests.scad
|
2011-09-08 10:21:53 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/include-tests.scad
|
2011-09-08 10:52:31 +04:00
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/child-tests.scad
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/ifelse-tests.scad)
|
2011-09-02 04:48:22 +04:00
|
|
|
#LIST(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
|
2011-09-01 22:04:01 +04:00
|
|
|
add_cmdline_test(cgalpngtest png ${CGALPNGTEST_FILES})
|
2010-09-07 04:05:08 +04:00
|
|
|
|
2011-08-04 20:26:25 +04:00
|
|
|
# Add opencsg tests to CTest
|
2011-09-02 00:44:16 +04:00
|
|
|
LIST(APPEND OPENCSGTEST_FILES ${CGALPNGTEST_FILES})
|
2011-09-29 00:32:35 +04:00
|
|
|
LIST(APPEND OPENCSGTEST_FILES
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/highlight-and-background-modifier.scad
|
|
|
|
${CMAKE_SOURCE_DIR}/../testdata/scad/features/child-background.scad)
|
2011-09-04 04:53:30 +04:00
|
|
|
add_cmdline_test(opencsgtest png ${OPENCSGTEST_FILES})
|
2011-08-04 20:26:25 +04:00
|
|
|
|
2010-07-11 23:06:43 +04:00
|
|
|
# Add dxfexport tests to CTest
|
2010-08-31 01:57:11 +04:00
|
|
|
#add_cmdline_test(${CMAKE_SOURCE_DIR}/../test-code/exportdxf dxf ${SCAD_FILES})
|