Permalink
Browse files

Added cmake support.

  • Loading branch information...
1 parent e2db618 commit 558bf33c8877db064ff5d5b4ddbb7543f473276f Brent Burley committed Mar 8, 2012
Showing with 137 additions and 0 deletions.
  1. +30 −0 README
  2. +17 −0 src/CMakeLists.txt
  3. +13 −0 src/doc/CMakeLists.txt
  4. +19 −0 src/ptex/CMakeLists.txt
  5. +32 −0 src/tests/CMakeLists.txt
  6. +13 −0 src/tests/compare_test.cmake
  7. +13 −0 src/utils/CMakeLists.txt
View
30 README
@@ -0,0 +1,30 @@
+Building with make (Linux):
+> cd src
+> make
+
+This will build, install to a local 'install' directory, and
+run regression tests.
+
+Contents of install directory:
+install/bin:
+ptxinfo
+
+install/include:
+PtexHalf.h PtexInt.h Ptexture.h PtexUtils.h
+
+install/lib:
+libPtex.a libPtex.so
+
+
+
+Building with cmake:
+mkdir build
+cd build
+cmake ../src
+make
+make test
+make install
+make doc
+
+Note: docs will be generated into local 'install' directory.
+(TODO: generate in build directory.)
View
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 2.8)
+project(ptex)
+
+# enable testing for the project
+include(CTest)
+enable_testing()
+
+include(FindZLIB)
+include(FindThreads)
+
+include_directories(ptex)
+include_directories(${ZLIB_INCLUDE_DIR})
+
+add_subdirectory(ptex)
+add_subdirectory(utils)
+add_subdirectory(tests)
+add_subdirectory(doc)
View
@@ -0,0 +1,13 @@
+find_package ( Doxygen )
+
+file ( MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/../install/doc)
+
+if (DOXYGEN_FOUND)
+ set (generated_doc_location ${CMAKE_SOURCE_DIR}/../install/doc/ptex/)
+ set (doxyfile_location ${CMAKE_SOURCE_DIR}/doc/)
+ set (perm OWNER_READ GROUP_READ WORLD_READ)
+ add_custom_target (doc
+ ${DOXYGEN_EXECUTABLE} ${doxyfile_location}/Doxyfile
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc
+ )
+endif (DOXYGEN_FOUND)
View
@@ -0,0 +1,19 @@
+set(SRCS
+ PtexCache.cpp
+ PtexFilters.cpp
+ PtexHalf.cpp
+ PtexReader.cpp
+ PtexSeparableFilter.cpp
+ PtexSeparableKernel.cpp
+ PtexTriangleFilter.cpp
+ PtexTriangleKernel.cpp
+ PtexUtils.cpp
+ PtexWriter.cpp)
+
+add_library ( Ptex_static STATIC ${SRCS} )
+set_target_properties( Ptex_static PROPERTIES OUTPUT_NAME Ptex )
+
+add_library ( Ptex_dynamic SHARED ${SRCS} )
+set_target_properties(Ptex_dynamic PROPERTIES OUTPUT_NAME Ptex)
+
+target_link_libraries(Ptex_dynamic ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES} )
View
@@ -0,0 +1,32 @@
+add_executable(wtest wtest.cpp)
+target_link_libraries(wtest Ptex)
+
+add_executable(rtest rtest.cpp)
+target_link_libraries(rtest Ptex)
+
+add_executable(ftest ftest.cpp)
+target_link_libraries(ftest Ptex)
+
+add_executable(halftest halftest.cpp)
+target_link_libraries(halftest Ptex)
+
+# create a function to add tests that compare output
+# file results
+function(add_compare_test test_name)
+ add_test(NAME ${test_name}
+ COMMAND ${CMAKE_COMMAND}
+ -DOUT=${CMAKE_CURRENT_BINARY_DIR}/${test_name}.out
+ -DDATA=${CMAKE_CURRENT_SOURCE_DIR}/${test_name}ok.dat
+ -DCMD=$<TARGET_FILE:${test_name}>
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/compare_test.cmake)
+endfunction(add_compare_test)
+
+# add all the tests
+add_test(NAME wtest COMMAND $<TARGET_FILE:wtest>)
+add_compare_test(rtest)
+add_compare_test(ftest)
+add_test(NAME halftest COMMAND $<TARGET_FILE:halftest>)
+
+
+
+
@@ -0,0 +1,13 @@
+message("Run ${CMD} to produce: ${OUT} and compare with: ${DATA}")
+# run the test
+execute_process(COMMAND "${CMD}" OUTPUT_FILE "${OUT}" RESULT_VARIABLE ret)
+if(NOT ${ret} EQUAL 0)
+ message(FATAL_ERROR "${CMD} returned a non-zero value:${ret}")
+endif()
+# use cmake executable to compare the output of the tests
+execute_process(COMMAND "${CMAKE_COMMAND}" -E compare_files "${OUT}" "${DATA}"
+ RESULT_VARIABLE ret)
+if(NOT ${ret} EQUAL 0)
+ message(FATAL_ERROR
+ "compare_files ${OUT} ${DATA} returned a non-zero value:${ret}")
+endif()
View
@@ -0,0 +1,13 @@
+# build version string from git query
+execute_process(COMMAND git rev-list --max-count=1 HEAD
+ OUTPUT_VARIABLE PTEX_SHA
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND git describe ${PTEX_SHA}
+ OUTPUT_VARIABLE PTEX_VER
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+add_executable(ptxinfo ptxinfo.cpp)
+add_definitions(-DPTEX_VER="${PTEX_VER} \(${PTEX_SHA}\)")
+target_link_libraries(ptxinfo Ptex)
+
+

0 comments on commit 558bf33

Please sign in to comment.