openscad/tests/CMakeLists.txt

127 lines
4.3 KiB
CMake
Raw Normal View History

2010-07-07 02:54:16 +04:00
cmake_minimum_required(VERSION 2.8)
project(tests)
#
# Build test apps
#
# Qt4
find_package(OpenGL)
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
include(${QT_USE_FILE})
include_directories(../src)
# 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()
endif()
2010-08-31 02:49:24 +04:00
include_directories(${EIGEN2_INCLUDE_DIR})
# 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
../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
../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
../src/PolySetRenderer.cc
../src/Tree.cc
${FLEX_OpenSCADlexer_OUTPUTS}
${BISON_OpenSCADparser_OUTPUTS})
2010-08-31 02:49:24 +04:00
add_executable(dumptest dumptest.cc ${COMMON_SOURCES})
target_link_libraries(dumptest ${QT_LIBRARIES} ${OPENGL_LIBRARY})
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})
add_executable(csgtermtest csgtermtest.cc ../src/CSGTermRenderer.cc ${COMMON_SOURCES})
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})
add_executable(cgaltest cgaltest.cc ../src/CSGTermRenderer.cc ../src/CGALRenderer.cc
../src/PolySetCGALRenderer.cc ../src/qhash.cc ../src/nef2dxf.cc
../src/nef2dxf.cc ../src/cgaladv_minkowski2.cc
../src/cgaladv_minkowski3.cc ${COMMON_SOURCES})
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-09-07 04:05:08 +04:00
# This functions adds cmd-line tests given files.
# Files are sent as the parameters following TESTSUFFIX
#
2010-09-07 04:05:08 +04:00
function(add_cmdline_test TESTCMD TESTSUFFIX)
get_filename_component(TESTCMD_NAME ${TESTCMD} NAME_WE)
2010-09-07 04:05:08 +04:00
foreach (SCADFILE ${ARGN})
get_filename_component(TESTNAME ${SCADFILE} NAME_WE)
2010-09-07 04:05:08 +04:00
add_test(${TESTCMD_NAME}_${TESTNAME} ${tests_SOURCE_DIR}/test_cmdline_tool.py -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} ${SCADFILE})
endforeach()
endfunction()
2010-07-07 02:54:16 +04:00
enable_testing()
# Find all scad files
file(GLOB SCAD_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/*.scad)
# Add dumptest tests to CTest
add_cmdline_test(dumptest txt ${SCAD_FILES})
2010-07-07 03:44:58 +04:00
# Add csgtexttest tests to CTest
2010-08-31 02:49:24 +04:00
add_cmdline_test(csgtexttest txt ${SCAD_FILES})
# Add csgtermtest tests to CTest
add_cmdline_test(csgtermtest txt ${SCAD_FILES})
2010-07-09 02:46:19 +04:00
# Add cgaltest tests to CTest
2010-09-07 04:05:08 +04:00
LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/cube.scad)
LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/sphere.scad)
LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/cylinder.scad)
LIST(APPEND CGALTEST_FILES ${CMAKE_SOURCE_DIR}/../examples/example001.scad)
add_cmdline_test(cgaltest stl ${CGALTEST_FILES})
# Add dxfexport tests to CTest
#add_cmdline_test(${CMAKE_SOURCE_DIR}/../test-code/exportdxf dxf ${SCAD_FILES})