travis-ci.cmake 5.6 KB

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