Fix OPJ_CI_SKIP_TESTS
[openjpeg.git] / tools / ctest_scripts / travis-ci.cmake
1 # -----------------------------------------------------------------------------
2 # Travis-ci ctest script for OpenJPEG project
3 # This will compile/run tests/upload to cdash OpenJPEG
4 # Results will be available at: http://my.cdash.org/index.php?project=OPENJPEG
5 # -----------------------------------------------------------------------------
6
7 cmake_minimum_required(VERSION 2.8)
8
9 set( ENV{LANG} en_US.UTF-8)
10 set( CTEST_DASHBOARD_ROOT  "$ENV{PWD}/build" )
11 set( CTEST_CMAKE_GENERATOR "Unix Makefiles")   # Always makefile in travis-ci environment
12
13 if ("$ENV{OPJ_BUILD_CONFIGURATION}" STREQUAL "")
14   set( CTEST_BUILD_CONFIGURATION "Release")
15 else()
16         set( CTEST_BUILD_CONFIGURATION "$ENV{OPJ_BUILD_CONFIGURATION}")
17 endif()
18
19 if ("$ENV{OPJ_SITE}" STREQUAL "")
20   set( CTEST_SITE "Unknown")
21 else()
22         set( CTEST_SITE "$ENV{OPJ_SITE}")
23 endif()
24
25 if ("$ENV{OPJ_BUILDNAME}" STREQUAL "")
26   set( CTEST_BUILD_NAME "Unknown-${CTEST_BUILD_CONFIGURATION}")
27 else()
28         set( CTEST_BUILD_NAME "$ENV{OPJ_BUILDNAME}")
29 endif()
30
31 if (NOT "$ENV{OPJ_CI_ARCH}" STREQUAL "")
32         if (APPLE)
33           set(CCFLAGS_ARCH "-arch $ENV{OPJ_CI_ARCH}")
34         else()
35                 if ("$ENV{OPJ_CI_ARCH}" MATCHES "^i[3-6]86$")
36                         set(CCFLAGS_ARCH "-m32 -march=$ENV{OPJ_CI_ARCH}")
37                 elseif ("$ENV{OPJ_CI_ARCH}" STREQUAL "x86_64")
38                         set(CCFLAGS_ARCH "-m64")
39                 endif()
40         endif()
41 endif()
42
43 if(NOT "$ENV{OPJ_CI_SKIP_TESTS}" STREQUAL "1")
44         # To execute part of the encoding test suite, kakadu binaries are needed to decode encoded image and compare 
45         # it to the baseline. Kakadu binaries are freely available for non-commercial purposes 
46         # at http://www.kakadusoftware.com.
47         # Here's the copyright notice from kakadu:
48         # Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
49         # You are free to trial these executables and even to re-distribute them,
50         # so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
51         # Note: Binaries can only be used for non-commercial purposes.
52         if ("$ENV{OPJ_NONCOMMERCIAL}" STREQUAL "1" )
53                 set(KDUPATH $ENV{PWD}/kdu)
54                 set(ENV{LD_LIBRARY_PATH} ${KDUPATH})
55                 set(ENV{PATH} $ENV{PATH}:${KDUPATH})
56         endif()
57         set(BUILD_TESTING "TRUE")
58 else()
59         set(BUILD_TESTING "FALSE")
60 endif(NOT "$ENV{OPJ_CI_SKIP_TESTS}" STREQUAL "1")
61
62 # Options 
63 set( CACHE_CONTENTS "
64
65 # Build kind
66 CMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION}
67
68 # Warning level
69 CMAKE_C_FLAGS:STRING= ${CCFLAGS_ARCH} -Wall -Wextra -Wconversion -Wno-unused-parameter -Wdeclaration-after-statement
70
71 # Use to activate the test suite
72 BUILD_TESTING:BOOL=${BUILD_TESTING}
73
74 # Build Thirdparty, useful but not required for test suite 
75 BUILD_THIRDPARTY:BOOL=TRUE
76
77 # JPEG2000 test files are available with git clone https://github.com/uclouvain/openjpeg-data.git
78 OPJ_DATA_ROOT:PATH=$ENV{PWD}/data
79
80 # jpylyzer is available with on GitHub: https://github.com/openpreserve/jpylyzer  
81 JPYLYZER_EXECUTABLE=$ENV{PWD}/jpylyzer/jpylyzer/jpylyzer.py
82
83 " )
84
85 #---------------------
86 #1. openjpeg specific: 
87 set( CTEST_PROJECT_NAME "OPENJPEG" )
88 if(NOT EXISTS $ENV{OPJ_SOURCE_DIR})
89         message(FATAL_ERROR "OPJ_SOURCE_DIR not defined or does not exist:$ENV{OPJ_SOURCE_DIR}")
90 endif()
91 set( CTEST_SOURCE_DIRECTORY     "$ENV{OPJ_SOURCE_DIR}")
92 set( CTEST_BINARY_DIRECTORY     "${CTEST_DASHBOARD_ROOT}")
93
94 #---------------------
95 # Files to submit to the dashboard
96 set (CTEST_NOTES_FILES
97 ${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}
98 ${CTEST_BINARY_DIRECTORY}/CMakeCache.txt )
99
100 ctest_empty_binary_directory( "${CTEST_BINARY_DIRECTORY}" )
101 file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "${CACHE_CONTENTS}")
102
103 # Perform a Experimental build
104 ctest_start(Experimental)
105 #ctest_update(SOURCE "${CTEST_SOURCE_DIRECTORY}")
106 ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}")
107 ctest_read_custom_files(${CTEST_BINARY_DIRECTORY})
108 ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}")
109 if(NOT "$ENV{OPJ_CI_SKIP_TESTS}" STREQUAL "1")
110         ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL 2)
111 endif()
112 if ("$ENV{OPJ_DO_SUBMIT}" STREQUAL "1")
113         ctest_submit()
114 endif()
115 ctest_empty_binary_directory( "${CTEST_BINARY_DIRECTORY}" )