T1: fix BYPASS/LAZY, TERMALL/RESTART and PTERM/ERTERM encoding modes. (#674)
[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 if($ENV{OPJ_BINARY_DIR})
11         set( CTEST_DASHBOARD_ROOT  "$ENV{OPJ_BINARY_DIR}" )
12 else()
13         set( CTEST_DASHBOARD_ROOT  "$ENV{PWD}/build" )
14 endif()
15
16 if("$ENV{TRAVIS_OS_NAME}" STREQUAL "windows")
17         set( CTEST_CMAKE_GENERATOR "NMake Makefiles")
18         set( CTEST_BUILD_COMMAND   "nmake" )
19         set( JPYLYZER_EXT          "exe"  )
20 else()
21         set( CTEST_CMAKE_GENERATOR "Unix Makefiles")   # Always makefile in travis-ci environment
22         set( CCFLAGS_WARNING "-Wall -Wextra -Wconversion -Wno-unused-parameter -Wdeclaration-after-statement -Werror=declaration-after-statement")
23         set( JPYLYZER_EXT          "py"  )
24 endif()
25
26 if ("$ENV{OPJ_BUILD_CONFIGURATION}" STREQUAL "")
27   set( CTEST_BUILD_CONFIGURATION "Release")
28 else()
29         set( CTEST_BUILD_CONFIGURATION "$ENV{OPJ_BUILD_CONFIGURATION}")
30 endif()
31
32 if ("$ENV{OPJ_SITE}" STREQUAL "")
33   set( CTEST_SITE "Unknown")
34 else()
35         set( CTEST_SITE "$ENV{OPJ_SITE}")
36 endif()
37
38 if ("$ENV{OPJ_BUILDNAME}" STREQUAL "")
39   set( CTEST_BUILD_NAME "Unknown-${CTEST_BUILD_CONFIGURATION}")
40 else()
41         set( CTEST_BUILD_NAME "$ENV{OPJ_BUILDNAME}")
42 endif()
43
44 if (NOT "$ENV{OPJ_CI_ARCH}" STREQUAL "")
45         if (APPLE)
46           set(CCFLAGS_ARCH "-arch $ENV{OPJ_CI_ARCH}")
47         else()
48                 if ("$ENV{OPJ_CI_ARCH}" MATCHES "^i[3-6]86$")
49                         set(CCFLAGS_ARCH "-m32 -march=$ENV{OPJ_CI_ARCH}")
50                 elseif ("$ENV{OPJ_CI_ARCH}" STREQUAL "x86_64")
51                         set(CCFLAGS_ARCH "-m64")
52                 endif()
53         endif()
54 endif()
55
56 if ("$ENV{OPJ_CI_ASAN}" STREQUAL "1")
57         set(OPJ_HAS_MEMCHECK TRUE)
58         set(CTEST_MEMORYCHECK_TYPE "AddressSanitizer")
59         set(CCFLAGS_ARCH "${CCFLAGS_ARCH} -O1 -g -fsanitize=address -fno-omit-frame-pointer")
60 endif()
61
62 if("$ENV{CC}" MATCHES ".*mingw.*")
63         # We are trying to use mingw
64         if ("$ENV{OPJ_CI_ARCH}" MATCHES "^i[3-6]86$")
65                 set(CTEST_CONFIGURE_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${CTEST_SCRIPT_DIRECTORY}/toolchain-mingw32.cmake")
66         else()
67                 set(CTEST_CONFIGURE_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${CTEST_SCRIPT_DIRECTORY}/toolchain-mingw64.cmake")
68         endif()
69 endif()
70
71 if(NOT "$ENV{OPJ_CI_SKIP_TESTS}" STREQUAL "1")
72         # To execute part of the encoding test suite, kakadu binaries are needed to decode encoded image and compare
73         # it to the baseline. Kakadu binaries are freely available for non-commercial purposes
74         # at http://www.kakadusoftware.com.
75         # Here's the copyright notice from kakadu:
76         # Copyright is owned by NewSouth Innovations Pty Limited, commercial arm of the UNSW Australia in Sydney.
77         # You are free to trial these executables and even to re-distribute them,
78         # so long as such use or re-distribution is accompanied with this copyright notice and is not for commercial gain.
79         # Note: Binaries can only be used for non-commercial purposes.
80         if ("$ENV{OPJ_NONCOMMERCIAL}" STREQUAL "1" )
81                 set(KDUPATH $ENV{PWD}/kdu)
82                 if("$ENV{TRAVIS_OS_NAME}" STREQUAL "windows")
83                         set(ENV{PATH} "$ENV{PATH};${KDUPATH}")
84                 else()
85                         set(ENV{LD_LIBRARY_PATH} ${KDUPATH})
86                         set(ENV{PATH} $ENV{PATH}:${KDUPATH})
87                 endif()
88         endif()
89         set(BUILD_TESTING "TRUE")
90 else()
91         set(BUILD_TESTING "FALSE")
92 endif(NOT "$ENV{OPJ_CI_SKIP_TESTS}" STREQUAL "1")
93
94
95 if("$ENV{OPJ_CI_CHECK_STYLE}" STREQUAL "1")
96         set(BUILD_ASTYLE "TRUE")
97 else()
98         set(BUILD_ASTYLE "FALSE")
99 endif("$ENV{OPJ_CI_CHECK_STYLE}" STREQUAL "1")
100
101 # Options
102 set( CACHE_CONTENTS "
103
104 # Build kind
105 CMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION}
106
107 # Warning level
108 CMAKE_C_FLAGS:STRING= ${CCFLAGS_ARCH} ${CCFLAGS_WARNING}
109
110 # For astyle
111 CMAKE_CXX_FLAGS:STRING= ${CCFLAGS_ARCH}
112
113 # Use to activate the test suite
114 BUILD_TESTING:BOOL=${BUILD_TESTING}
115
116 # Build Thirdparty, useful but not required for test suite
117 BUILD_THIRDPARTY:BOOL=TRUE
118
119 # JPEG2000 test files are available with git clone https://github.com/uclouvain/openjpeg-data.git
120 OPJ_DATA_ROOT:PATH=$ENV{PWD}/data
121
122 # jpylyzer is available with on GitHub: https://github.com/openpreserve/jpylyzer
123 JPYLYZER_EXECUTABLE=$ENV{PWD}/jpylyzer/jpylyzer.${JPYLYZER_EXT}
124
125 # Enable astyle
126 WITH_ASTYLE:BOOL=${BUILD_ASTYLE}
127 " )
128
129 #---------------------
130 #1. openjpeg specific:
131 set( CTEST_PROJECT_NAME "OPENJPEG" )
132 if(NOT EXISTS $ENV{OPJ_SOURCE_DIR})
133         message(FATAL_ERROR "OPJ_SOURCE_DIR not defined or does not exist:$ENV{OPJ_SOURCE_DIR}")
134 endif()
135 set( CTEST_SOURCE_DIRECTORY     "$ENV{OPJ_SOURCE_DIR}")
136 set( CTEST_BINARY_DIRECTORY     "${CTEST_DASHBOARD_ROOT}")
137
138 #---------------------
139 # Files to submit to the dashboard
140 set (CTEST_NOTES_FILES
141 ${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}
142 ${CTEST_BINARY_DIRECTORY}/CMakeCache.txt )
143
144 ctest_empty_binary_directory( "${CTEST_BINARY_DIRECTORY}" )
145 file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "${CACHE_CONTENTS}")
146
147 # Perform a Experimental build
148 ctest_start(Experimental)
149 #ctest_update(SOURCE "${CTEST_SOURCE_DIRECTORY}")
150 ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" OPTIONS "${CTEST_CONFIGURE_OPTIONS}")
151 ctest_read_custom_files(${CTEST_BINARY_DIRECTORY})
152 ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}")
153 if(NOT "$ENV{OPJ_CI_SKIP_TESTS}" STREQUAL "1")
154         ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL 2)
155         if(OPJ_HAS_MEMCHECK)
156                 ctest_memcheck(BUILD "${CTEST_BINARY_DIRECTORY}" PARALLEL_LEVEL 2)
157         endif()
158 endif()
159 if ("$ENV{OPJ_DO_SUBMIT}" STREQUAL "1")
160         ctest_submit()
161 endif()
162 # Do not clean, we'll parse the log for known failure
163 #ctest_empty_binary_directory( "${CTEST_BINARY_DIRECTORY}" )