Commit aad2b3d4 authored by Vincent Pinon's avatar Vincent Pinon

Check compiler before setting options

parent 36ea3371
Pipeline #22445 passed with stage
in 15 minutes and 3 seconds
......@@ -18,13 +18,6 @@ if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif()
if(BUILD_FUZZING)
set(CMAKE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -fsanitize=fuzzer-no-link,address")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
endif()
# To be switched on when releasing.
option(RELEASE_BUILD "Remove Git revision from program version" ON)
option(BUILD_TESTING "Build tests" ON)
......@@ -125,7 +118,15 @@ feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAG
set(FFMPEG_SUFFIX "" CACHE STRING "FFmpeg custom suffix")
configure_file(config-kdenlive.h.cmake config-kdenlive.h @ONLY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wno-suggest-override")
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-override")
set(KDENLIVE_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wall -pedantic -Wextra")
endif()
# Sources
add_subdirectory(src)
......@@ -143,31 +144,11 @@ else()
install(FILES kdenlive.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
endif()
############################
# Tests
############################
if(BUILD_TESTING)
message(STATUS "Building tests")
add_subdirectory(tests)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexceptions")
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/src
${MLT_INCLUDE_DIR}
${MLTPP_INCLUDE_DIR}
src)
add_executable(runTests ${Tests_SRCS})
set_property(TARGET runTests PROPERTY CXX_STANDARD 14)
target_link_libraries(runTests kdenliveLib)
add_test(NAME runTests COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/runTests -d yes)
endif()
if(BUILD_FUZZING)
message(STATUS "Building fuzzing")
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDENLIVE_CXX_FLAGS} -fsanitize=fuzzer-no-link,address")
if(BUILD_FUZZING AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_subdirectory(fuzzer)
endif()
############################
# fuzzing
########################
if(POLICY CMP0079)
cmake_policy(SET CMP0079 NEW)
endif()
project(Kdenlive_fuzzing)
SET(FUZZING_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wall -pedantic -Wextra -fexceptions -O1 -fsanitize=fuzzer,address -g")
SET(fuzzing_SRCS
main_fuzzer.cpp
fuzzing.cpp
)
SET(reproduce_SRCS
main_reproducer.cpp
fuzzing.cpp
)
ADD_EXECUTABLE(fuzz ${fuzzing_SRCS})
ADD_EXECUTABLE(fuzz_reproduce ${reproduce_SRCS})
include_directories(${MLT_INCLUDE_DIR})
add_executable(fuzz main_fuzzer.cpp fuzzing.cpp)
add_executable(fuzz_reproduce main_reproducer.cpp fuzzing.cpp)
target_link_libraries(fuzz kdenliveLib)
target_link_libraries(fuzz_reproduce kdenliveLib)
#target_link_options(fuzz PUBLIC "-fsanitize=fuzzer")
set_target_properties(fuzz PROPERTIES LINK_FLAGS "-fsanitize=fuzzer")
set_property(TARGET fuzz PROPERTY CXX_STANDARD 14)
set_property(TARGET fuzz_reproduce PROPERTY CXX_STANDARD 14)
set_target_properties(fuzz PROPERTIES COMPILE_FLAGS "${FUZZING_CXX_FLAGS}")
set_target_properties(fuzz PROPERTIES COMPILE_FLAGS "-O1 -g -Wall -pedantic -Wextra -fexceptions -fsanitize=fuzzer,address")
set_target_properties(fuzz PROPERTIES LINK_FLAGS "-fsanitize=fuzzer")
......@@ -156,22 +156,7 @@ if(BUILD_COVERAGE)
target_link_libraries(kdenliveLib gcov)
endif()
set_property(TARGET kdenliveLib PROPERTY CXX_STANDARD 14)
SET(KDENLIVE_CXX_FLAGS "${DEFAULT_CXX_FLAGS} -Wall -pedantic -Wextra")
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wcast-qual -Wcast-align -Wfloat-equal -Wpointer-arith")
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wunreachable-code -Wchar-subscripts -Wcomment -Wformat")
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wmain -Wmissing-braces")
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wparentheses -Wsequence-point -Wreturn-type -Wswitch")
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wuninitialized -Wreorder -Wundef -Wshadow -Wwrite-strings")
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wmissing-noreturn -Wsign-compare -Wsign-conversion -Wunused")
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wstrict-aliasing -Wconversion -Wdisabled-optimization -Wno-undef")
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wunused-parameter -Wshadow -Wno-variadic-macros -Wno-float-conversion")
if(KDENLIVE_COMPILER_IS_GNUCXX)
SET(KDENLIVE_CXX_FLAGS "${KDENLIVE_CXX_FLAGS} -Wlogical-op -Wunsafe-loop-optimizations ")
endif()
set_target_properties(kdenliveLib PROPERTIES COMPILE_FLAGS "${KDENLIVE_CXX_FLAGS}")
add_definitions(${qt5gui_definitions} -DQT_STRICT_ITERATORS -DQT_NO_CAST_FROM_BYTEARRAY)
# To compile kiss_fft.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=c99")
# Optional deps
if(DRMINGW_FOUND)
......
# Create a static library from kiss_fft
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=c99")
find_package(Qt5Core REQUIRED)
include_directories(
${CMAKE_BINARY_DIR}
......@@ -9,4 +8,5 @@ add_library(kiss_fft STATIC
kiss_fft.c
tools/kiss_fftr.c
)
set_property(TARGET kiss_fft PROPERTY C_STANDARD 99)
target_link_libraries(kiss_fft Qt5::Core)
############################
# Tests
############################
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -fexceptions")
string (REPLACE "-std=gnu++11" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
SET(Tests_SRCS
tests/TestMain.cpp
tests/abortutil.cpp
tests/compositiontest.cpp
tests/effectstest.cpp
tests/groupstest.cpp
tests/keyframetest.cpp
tests/markertest.cpp
tests/modeltest.cpp
tests/regressions.cpp
tests/snaptest.cpp
tests/test_utils.cpp
tests/timewarptest.cpp
tests/treetest.cpp
tests/trimmingtest.cpp
PARENT_SCOPE
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
endif()
set(Tests_SRCS
TestMain.cpp
abortutil.cpp
compositiontest.cpp
effectstest.cpp
groupstest.cpp
keyframetest.cpp
markertest.cpp
modeltest.cpp
regressions.cpp
snaptest.cpp
test_utils.cpp
timewarptest.cpp
treetest.cpp
trimmingtest.cpp
)
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/src
${MLT_INCLUDE_DIR}
${MLTPP_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/lib/external
${CMAKE_CURRENT_SOURCE_DIR}/lib
../src
)
include_directories(${MLT_INCLUDE_DIR} ..)
add_executable(runTests ${Tests_SRCS})
set_property(TARGET runTests PROPERTY CXX_STANDARD 14)
target_link_libraries(runTests kdenliveLib)
add_test(NAME runTests COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/runTests -d yes)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment