Permalink
Browse files

CMake work -- added testing (with CTest) and packaging (with CPack).

N.B.: Old 'make' still does a build correctly, but this change BREAKS
'make test' -- from here on out, only CMake can run the testsuite!


git-svn-id: http://svn.openimageio.org/oiio/trunk@690 31904243-a364-42ac-a3db-9305396518ba
  • Loading branch information...
lgritz committed May 19, 2009
1 parent 202ec09 commit b24478cbc13fcc7d6dd10a42eabe2bd3710af01d
View
@@ -37,11 +37,11 @@ $(info OIIO_MAKE_FLAGS = ${OIIO_MAKE_FLAGS})
cmakesetup:
- - ${MKDIR} build/${platform}
+ - ${MKDIR} build/${platform}${variant}
( cd build/${platform}${variant} ; \
cmake -DCMAKE_INSTALL_PREFIX=${working_dir}/dist/${platform}${variant} \
+ ${OIIO_CMAKE_FLAGS} \
-DBOOST_ROOT=${BOOST_HOME} \
- ${OIIO_CMAKE_FLAGS} \
../../src )
cmake: cmakesetup
@@ -50,6 +50,9 @@ cmake: cmakesetup
cmakeinstall: cmake
( cd build/${platform}${variant} ; make ${OIIO_MAKE_FLAGS} install )
+cmaketest: cmake
+ ( cd build/${platform}${variant} ; make ${OIIO_MAKE_FLAGS} test )
+
package: cmakeinstall
( cd build/${platform}${variant} ; make ${OIIO_MAKE_FLAGS} package )
View
@@ -1,24 +1,26 @@
-PROJECT (OIIO)
+PROJECT (OpenImageIO)
+SET ( OpenImageIO_VERSION_MAJOR 0 )
+SET ( OpenImageIO_VERSION_MINOR 5 )
+SET ( OpenImageIO_VERSION_PATCH 0 )
+
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
SET (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
MESSAGE ( STATUS "Project source dir = ${PROJECT_SOURCE_DIR}" )
+MESSAGE ( STATUS "Project build dir = ${CMAKE_BINARY_DIR}" )
+
+#PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
+# MESSAGE ( FATAL_ERROR "Not allowed to run in-source build!" )
+#ENDIF ()
+
IF ( NOT CMAKE_BUILD_TYPE )
-# SET( CMAKE_BUILD_TYPE "RelWithDebInfo" )
SET( CMAKE_BUILD_TYPE "Release" )
ENDIF ()
-# set default install prefix to project root directory
-#IF ( CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" )
-# SET ( CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/dist" )
-#ENDIF ( CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" )
-
-
SET ( EMBEDPLUGINS OFF CACHE BOOL "Embed format plugins in libOpenImageIO" )
SET ( USE_OPENGL ON CACHE BOOL "Include OpenGL support" )
SET ( USE_QT ON CACHE BOOL "Include Qt support" )
-
SET(CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake/modules"
"${PROJECT_SOURCE_DIR}/cmake")
@@ -30,6 +32,12 @@ INCLUDE ( externalpackages )
INCLUDE_DIRECTORIES ("include")
+IF ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
+ ADD_DEFINITIONS ( "-DDEBUG=1" )
+ENDIF ()
+
+SET (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+
# Macro to add a build target for an IO plugin.
@@ -67,7 +75,6 @@ ADD_SUBDIRECTORY ( idiff )
ADD_SUBDIRECTORY ( igrep )
ADD_SUBDIRECTORY ( iinfo )
ADD_SUBDIRECTORY ( maketx )
-ADD_SUBDIRECTORY ( testtex )
ADD_SUBDIRECTORY ( iv )
# Add IO plugin directories
@@ -85,14 +92,42 @@ ENDIF ()
ADD_SUBDIRECTORY ( include )
ADD_SUBDIRECTORY ( doc )
-# Other TODO:
-# * test_libOpenImageIO
-# * testsuite
+
+
+# Testing
+INCLUDE ( CTest )
+ADD_SUBDIRECTORY ( testtex )
+ADD_SUBDIRECTORY ( test_libOpenImageIO )
+ADD_TEST ( libOpenImageIO ${CMAKE_BINARY_DIR}/test_libOpenImageIO/test_libOpenImageIO )
+# Ugh, I can't seem to ADD_SUBDIRECTORY the testsuite dir if it's not a true
+# subdirectory of source, so we fake it by creating a link. FIXME!
+EXEC_PROGRAM ( "cmake -E create_symlink ${PROJECT_SOURCE_DIR}/../testsuite ${PROJECT_SOURCE_DIR}/testsuite" )
+ADD_SUBDIRECTORY ( testsuite )
+
+
+# Packaging
+SET ( CPACK_PACKAGE_VERSION_MAJOR ${OpenImageIO_VERSION_MAJOR} )
+SET ( CPACK_PACKAGE_VERSION_MINOR ${OpenImageIO_VERSION_MINOR} )
+SET ( CPACK_PACKAGE_VERSION_PATCH ${OpenImageIO_VERSION_PATCH} )
+#SET ( CPACK_PACKAGE_DESCRIPTION_FILE ...FIXME... )
+#SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY ...FIXME... )
+#SET ( CPACK_PACKAGE_DESCRIPTION_FILE ...FIXME... )
+SET ( CPACK_PACKAGE_FILE_NAME OpenImageIO-${OpenImageIO_VERSION_MAJOR}.${OpenImageIO_VERSION_MINOR}.${OpenImageIO_VERSION_PATCH}-${platform} )
+#SET ( CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_SOURCE_DIR}/.. )
+#SET ( CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE" )
+#SET ( CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/../README" )
+#SET ( CPACK_RESOURCE_FILE_WELCOME ...FIXME... )
+#SET ( CPACK_PACKAGE_EXECUTABLES iv )
+#SET ( CPACK_STRIP_FILES ...FIXME... )
+SET ( CPACK_SOURCE_PACKAGE_FILE_NAME OpenImageIO-${OpenImageIO_VERSION_MAJOR}.${OpenImageIO_VERSION_MINOR}.${OpenImageIO_VERSION_PATCH}-source )
+#SET ( CPACK_SOURCE_STRIP_FILES ...FIXME... )
+#SET ( CPACK_SOURCE_IGNORE_FILES "\\.svn;\\.#;.*~" )
+SET ( CPACK_SOURCE_IGNORE_FILES ".*~" )
+INCLUDE ( CPack )
# TODO: equivalents of the old:
-# * make USE_GTEST=0
-# * make debug, profile
-# * make test, code_tests, suite_tests
# * make doxygen
# * make help
# * BOOST_DYNAMIC
+
+# Do TIFF, JPEG, PNG actually look in external?
@@ -142,3 +142,22 @@ MESSAGE (STATUS "QT4_FOUND=${QT4_FOUND}")
# end Qt setup
###########################################################################
+###########################################################################
+# Gtest (Google Test) setup
+
+SET ( GTEST_VERSION 1.3.0 )
+find_library ( GTEST_LIBRARY
+ NAMES gtest
+ PATHS ${THIRD_PARTY_TOOLS_HOME}/lib/ )
+find_path ( GTEST_INCLUDES gtest/gtest.h
+ ${THIRD_PARTY_TOOLS}/include/gtest-${GTEST_VERSION} )
+IF (GTEST_INCLUDES AND GTEST_LIBRARY )
+ SET ( GTEST_FOUND TRUE )
+ MESSAGE ( STATUS "Gtest includes = ${GTEST_INCLUDES}" )
+ MESSAGE ( STATUS "Gtest library = ${GTEST_LIBRARY}" )
+ELSE ()
+ MESSAGE ( STATUS "Gtest not found" )
+ENDIF ()
+
+# end Gtest setup
+###########################################################################
View
@@ -31,14 +31,3 @@ IF ( platform )
ELSE ()
MESSAGE (FATAL_ERROR "'platform' not defined")
ENDIF ()
-
-
-
-###########################################################################
-# Platform-specific definitions
-
-IF ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
- SET (SYSTEM_DL_LIB dl)
-ELSE ()
- SET (SYSTEM_DL_LIB)
-ENDIF ()
@@ -1,5 +1,5 @@
SET ( iconvert_srcs iconvert.cpp )
ADD_EXECUTABLE ( iconvert ${iconvert_srcs} )
LINK_ILMBASE ( iconvert )
-TARGET_LINK_LIBRARIES ( iconvert OpenImageIO ${Boost_LIBRARIES} ${SYSTEM_DL_LIB} )
+TARGET_LINK_LIBRARIES ( iconvert OpenImageIO ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
INSTALL ( TARGETS iconvert RUNTIME DESTINATION bin )
View
@@ -1,5 +1,5 @@
SET ( idiff_srcs idiff.cpp )
ADD_EXECUTABLE ( idiff ${idiff_srcs} )
LINK_ILMBASE ( idiff )
-TARGET_LINK_LIBRARIES ( idiff OpenImageIO ${Boost_LIBRARIES} ${SYSTEM_DL_LIB})
+TARGET_LINK_LIBRARIES ( idiff OpenImageIO ${Boost_LIBRARIES} ${CMAKE_DL_LIBS})
INSTALL ( TARGETS idiff RUNTIME DESTINATION bin )
View
@@ -1,5 +1,5 @@
SET ( igrep_srcs igrep.cpp )
ADD_EXECUTABLE ( igrep ${igrep_srcs} )
LINK_ILMBASE ( igrep )
-TARGET_LINK_LIBRARIES ( igrep OpenImageIO ${Boost_LIBRARIES} ${SYSTEM_DL_LIB} )
+TARGET_LINK_LIBRARIES ( igrep OpenImageIO ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
INSTALL ( TARGETS igrep RUNTIME DESTINATION bin )
View
@@ -1,5 +1,5 @@
SET ( iinfo_srcs iinfo.cpp md5.cpp )
ADD_EXECUTABLE ( iinfo ${iinfo_srcs} )
LINK_ILMBASE ( iinfo )
-TARGET_LINK_LIBRARIES ( iinfo OpenImageIO ${Boost_LIBRARIES} ${SYSTEM_DL_LIB} )
+TARGET_LINK_LIBRARIES ( iinfo OpenImageIO ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
INSTALL ( TARGETS iinfo RUNTIME DESTINATION bin )
View
@@ -7,7 +7,7 @@ IF ( QT4_FOUND AND OPENGL_FOUND )
ADD_EXECUTABLE ( iv ${iv_srcs} )
LINK_ILMBASE ( iv )
TARGET_LINK_LIBRARIES ( iv OpenImageIO ${QT_LIBRARIES} ${OPENGL_LIBRARIES}
- ${Boost_LIBRARIES} ${SYSTEM_DL_LIB} )
+ ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
INSTALL ( TARGETS iv RUNTIME DESTINATION bin )
ELSE ()
@@ -1,5 +1,5 @@
SET ( maketx_srcs maketx.cpp )
ADD_EXECUTABLE ( maketx ${maketx_srcs} )
LINK_ILMBASE ( maketx )
-TARGET_LINK_LIBRARIES ( maketx OpenImageIO ${Boost_LIBRARIES} ${SYSTEM_DL_LIB} )
+TARGET_LINK_LIBRARIES ( maketx OpenImageIO ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
INSTALL ( TARGETS maketx RUNTIME DESTINATION bin )
@@ -0,0 +1,7 @@
+IF ( GTEST_FOUND )
+ ADD_EXECUTABLE ( test_libOpenImageIO test_imageio.cpp )
+ INCLUDE_DIRECTORIES ( ${GTEST_INCLUDES} )
+ LINK_ILMBASE ( test_libOpenImageIO )
+ TARGET_LINK_LIBRARIES ( test_libOpenImageIO OpenImageIO ${Boost_LIBRARIES}
+ ${GTEST_LIBRARY} ${CMAKE_DL_LIBS} )
+ENDIF ()
@@ -1,5 +1,4 @@
SET ( testtex_srcs testtex.cpp )
ADD_EXECUTABLE ( testtex ${testtex_srcs} )
LINK_ILMBASE ( testtex )
-TARGET_LINK_LIBRARIES ( testtex OpenImageIO ${Boost_LIBRARIES} ${SYSTEM_DL_LIB} )
-#INSTALL ( TARGETS testtex RUNTIME DESTINATION bin )
+TARGET_LINK_LIBRARIES ( testtex OpenImageIO ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
View
@@ -0,0 +1,8 @@
+MACRO ( RUNTEST testname )
+ ADD_TEST ( ${testname} python ${PROJECT_SOURCE_DIR}/../testsuite/tests/${testname}/run.py ${PROJECT_SOURCE_DIR}/../testsuite/tests/${testname} ${CMAKE_BINARY_DIR} )
+ # MESSAGE (STATUS "${testname} python ${PROJECT_SOURCE_DIR}/../testsuite/tests/${testname}/run.py ${PROJECT_SOURCE_DIR}/../testsuite/tests/${testname} ${CMAKE_BINARY_DIR}" )
+ENDMACRO ()
+
+RUNTEST ( ico )
+RUNTEST ( gpsread )
+
@@ -1,7 +1,16 @@
#!/usr/bin/python
+import os
+import sys
+
+path = ""
+command = ""
+if len(sys.argv) > 2 :
+ os.chdir (sys.argv[1])
+ path = sys.argv[2] + "/"
+
# A command to run
-command = "iinfo -v ../../../../oiio-testimages/tahoe-gps.jpg > out.txt"
+command = path + "iinfo/iinfo -v ../../../../oiio-testimages/tahoe-gps.jpg > out.txt"
# Outputs to check against references
outputs = [ "out.txt" ]
View
@@ -1,9 +1,18 @@
#!/usr/bin/python
+import os
+import sys
+
+path = ""
+command = ""
+if len(sys.argv) > 2 :
+ os.chdir (sys.argv[1])
+ path = sys.argv[2] + "/"
+
# A command to run
-command = "iconvert ../../../../oiio-testimages/oiio.ico test.ico > out.txt; \
-idiff -a ../../../../oiio-testimages/oiio.ico test.ico >> out.txt; \
-iinfo -v -a --md5 ../../../../oiio-testimages/oiio.ico test.ico >> out.txt"
+command = path + "iconvert/iconvert ../../../../oiio-testimages/oiio.ico test.ico > out.txt; " + \
+path + "idiff/idiff -a ../../../../oiio-testimages/oiio.ico test.ico >> out.txt; " + \
+path + "iinfo/iinfo -v -a --md5 ../../../../oiio-testimages/oiio.ico test.ico >> out.txt"
# Outputs to check against references
outputs = [ "out.txt" ]

0 comments on commit b24478c

Please sign in to comment.