Skip to content

Commit

Permalink
Merge pull request halide#2189 from halide/srj-c11
Browse files Browse the repository at this point in the history
Use CMake 3.1x's standard for requesting C++11
  • Loading branch information
abadams authored Jul 12, 2017
2 parents ad7aabd + c9b20ba commit ed97f66
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 35 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

project(Halide)
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.1.3)

find_package(LLVM REQUIRED CONFIG)

Expand All @@ -10,6 +10,11 @@ message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Require C++11 for everything.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_MACOSX_RPATH ON)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
Expand Down Expand Up @@ -96,7 +101,6 @@ function(halide_project name folder)
add_executable("${name}" ${ARGN})
if (MSVC)
else()
target_compile_options("${name}" PUBLIC "-std=c++11") # Halide clients need C++11
target_compile_options("${name}" PUBLIC "-fno-rtti")
endif()
target_link_libraries("${name}" PRIVATE Halide)
Expand Down
1 change: 0 additions & 1 deletion apps/bilateral_grid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ halide_add_aot_library(bilateral_grid
add_executable(filter filter.cpp)
halide_add_aot_library_dependency(filter bilateral_grid)
use_image_io(filter)
target_compile_options(filter PRIVATE "-std=c++11")
2 changes: 1 addition & 1 deletion apps/blur/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_executable(blur_test test.cpp)
halide_add_aot_library_dependency(blur_test halide_blur)

if (NOT MSVC)
target_compile_options(blur_test PRIVATE "-std=c++11" "-O2" "-msse2")
target_compile_options(blur_test PRIVATE "-O2" "-msse2")
if (OPENMP_FOUND)
target_compile_options(blur_test PRIVATE ${OpenMP_CXX_FLAGS})
target_link_libraries(blur_test PRIVATE ${OpenMP_CXX_FLAGS})
Expand Down
3 changes: 0 additions & 3 deletions apps/c_backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ function(halide_add_aot_cpp_dependency TARGET AOT_LIBRARY_TARGET)
add_dependencies("${TARGET}" "${AOT_LIBRARY_TARGET}.exec_generator")

add_library(${AOT_LIBRARY_TARGET}.cpplib STATIC "${GENFILES_DIR}/${AOT_LIBRARY_TARGET}.cpp")
target_compile_options(${AOT_LIBRARY_TARGET}.cpplib PRIVATE "-std=c++11")
target_link_libraries("${TARGET}" PRIVATE ${AOT_LIBRARY_TARGET}.cpplib)
target_include_directories("${TARGET}" PRIVATE "${GENFILES_DIR}")
endfunction(halide_add_aot_cpp_dependency)
Expand Down Expand Up @@ -38,12 +37,10 @@ halide_add_aot_library(pipeline_cpp_native

# Final executable(s)
add_executable(run_c_backend_and_native run.cpp)
target_compile_options(run_c_backend_and_native PRIVATE "-std=c++11")
halide_add_aot_cpp_dependency(run_c_backend_and_native pipeline_c)
halide_add_aot_library_dependency(run_c_backend_and_native pipeline_native)

add_executable(run_c_backend_and_native_cpp run_cpp.cpp)
target_compile_options(run_c_backend_and_native_cpp PRIVATE "-std=c++11")
halide_add_aot_cpp_dependency(run_c_backend_and_native_cpp pipeline_cpp_cpp)
halide_add_aot_library_dependency(run_c_backend_and_native_cpp pipeline_cpp_native)

Expand Down
5 changes: 1 addition & 4 deletions apps/camera_pipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ FIND_PACKAGE(OpenMP)
if (OPENMP_FOUND)
target_compile_options(fcam PUBLIC "-fopenmp")
endif()
if (NOT MSVC)
target_compile_options(fcam PRIVATE "-std=c++11")
endif()

# Final executable
add_executable(process process.cpp)
Expand All @@ -23,7 +20,7 @@ target_link_libraries(process PRIVATE ${curved_lib} fcam)
use_image_io(process)

if (NOT MSVC)
target_compile_options(process PRIVATE "-std=c++11" "-O2" "-msse2")
target_compile_options(process PRIVATE "-O2" "-msse2")
if (OPENMP_FOUND)
target_compile_options(process PRIVATE ${OpenMP_CXX_FLAGS})
target_link_libraries(process PRIVATE ${OpenMP_CXX_FLAGS})
Expand Down
1 change: 0 additions & 1 deletion apps/glsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if (OpenGL_FOUND)
add_executable(opengl_test opengl_test.cpp)
halide_add_aot_library_dependency(opengl_test halide_blur_glsl)
halide_add_aot_library_dependency(opengl_test halide_ycc_glsl)
target_compile_options(opengl_test PRIVATE "-std=c++11")

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(opengl_test PRIVATE pthread dl X11 GL)
Expand Down
5 changes: 2 additions & 3 deletions apps/linear_algebra/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ endif()
add_executable(halide_benchmarks halide_benchmarks.cpp)
target_include_directories(halide_benchmarks PRIVATE ${halide_blas_INCLUDE_DIRS})
target_compile_definitions(halide_benchmarks PRIVATE -DUSE_HALIDE ${MISC_DEFINITIONS})
target_compile_options(halide_benchmarks PRIVATE -std=c++11)
target_link_libraries(halide_benchmarks PRIVATE halide_blas)
list(APPEND BLAS_NAMES halide)

Expand All @@ -43,7 +42,7 @@ if (Eigen3_FOUND)
eigen_benchmarks.cpp
)
target_compile_definitions(eigen_benchmarks PRIVATE -DEIGEN_DONT_PARALLELIZE ${MISC_DEFINITIONS})
target_compile_options(eigen_benchmarks PRIVATE -std=c++11 -Wno-error=unused-variable)
target_compile_options(eigen_benchmarks PRIVATE -Wno-error=unused-variable)
target_link_libraries(eigen_benchmarks
PRIVATE
Eigen3::Eigen
Expand All @@ -66,7 +65,7 @@ else()
)
string(TOUPPER ${BLAS_VENDOR} DEFINE_SUFFIX)
target_compile_definitions(${TARGET} PRIVATE -DUSE_${DEFINE_SUFFIX} ${MISC_DEFINITIONS})
target_compile_options(${TARGET} PRIVATE -std=c++11 -Wno-error=unused-variable)
target_compile_options(${TARGET} PRIVATE -Wno-error=unused-variable)
target_link_libraries(${TARGET}
PRIVATE
${BLAS_${NAME}_LIBRARY}
Expand Down
1 change: 0 additions & 1 deletion apps/linear_algebra/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ halide_add_generator(blas_l3.generator SRCS blas_l3_generators.cpp)
add_library(halide_blas
halide_blas.cpp
)
target_compile_options(halide_blas PRIVATE -std=c++11)

set(GENERATOR_OUTPUTS h static_library)
set(GENERATOR_TARGET host-no_asserts-no_bounds_query)
Expand Down
1 change: 0 additions & 1 deletion apps/local_laplacian/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ halide_add_aot_library(local_laplacian
add_executable(ll_process process.cpp)
halide_add_aot_library_dependency(ll_process local_laplacian)
use_image_io(ll_process)
target_compile_options(ll_process PRIVATE "-std=c++11")
4 changes: 2 additions & 2 deletions apps/wavelet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include_directories("${HALIDE_SRC_DIR}/include")
include_directories("${HALIDE_SRC_DIR}/tools")

add_executable(wavelet "${CMAKE_CURRENT_SOURCE_DIR}/wavelet.cpp")
target_compile_options(wavelet PRIVATE "-std=c++11" "-fno-rtti")
target_compile_options(wavelet PRIVATE "-fno-rtti")

find_package(PNG)
target_link_libraries(wavelet PRIVATE ${PNG_LIBRARIES})
Expand All @@ -42,7 +42,7 @@ foreach(GEN_SRC ${GENS})
# GEN_EXECUTABLE := *.generator
string(REPLACE "_generator.cpp" "" GEN_EXECUTABLE "${GEN_SRC}.generator")
add_executable("${GEN_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/GenGen.cpp" "${GEN_SRC}")
target_compile_options("${GEN_EXECUTABLE}" PRIVATE "-std=c++11" "-fno-rtti")
target_compile_options("${GEN_EXECUTABLE}" PRIVATE "-fno-rtti")
target_link_libraries("${GEN_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../../lib/libHalide.a" z)

halide_add_aot_library("${GEN_NAME}"
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ if (MSVC)
target_compile_options(Halide PRIVATE "/Zc:sizedDealloc-")
endif()
else()
target_compile_options(Halide PUBLIC "-std=c++11") # Halide and its clients need to use C++11
target_compile_options(Halide PUBLIC "-fno-rtti")
endif()

Expand Down
10 changes: 0 additions & 10 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ function(halide_define_aot_test NAME)
set(TARGET "generator_aot_${NAME}")

add_executable("${TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}/generator/${NAME}_aottest.cpp")
if (MSVC)
else()
target_compile_options("${TARGET}" PUBLIC "-std=c++11") # HalideBuffer.h needs C++11
endif()
target_include_directories("${TARGET}" PRIVATE "${CMAKE_SOURCE_DIR}/tools")
target_include_directories("${TARGET}" PRIVATE "${CMAKE_SOURCE_DIR}/src/runtime")
target_include_directories("${TARGET}" PRIVATE "${CMAKE_SOURCE_DIR}")
Expand Down Expand Up @@ -275,9 +271,6 @@ if (WITH_TEST_GENERATORS)

add_library(cxx_mangling_externs
"${CMAKE_CURRENT_SOURCE_DIR}/generator/cxx_mangling_externs.cpp")
if (NOT MSVC)
target_compile_options(cxx_mangling_externs PUBLIC "-std=c++11")
endif()

halide_define_aot_test(cxx_mangling
GENERATOR_HALIDE_TARGET host-c_plus_plus_name_mangling
Expand Down Expand Up @@ -347,9 +340,6 @@ if (WITH_TEST_GENERATORS)

add_library(cxx_mangling_define_extern_externs
"${CMAKE_CURRENT_SOURCE_DIR}/generator/cxx_mangling_define_extern_externs.cpp")
if (NOT MSVC)
target_compile_options(cxx_mangling_define_extern_externs PUBLIC "-std=c++11")
endif()
target_link_libraries(cxx_mangling_define_extern_externs PRIVATE cxx_mangling_externs)
halide_add_aot_library_dependency(cxx_mangling_define_extern_externs cxx_mangling)

Expand Down
1 change: 0 additions & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ target_compile_definitions(HalideToolsRunGen PUBLIC "-D_CRT_SECURE_NO_WARNINGS"
use_image_io(HalideToolsRunGen)
if (MSVC)
else()
target_compile_options(HalideToolsRunGen PUBLIC "-std=c++11") # Halide clients need C++11
target_compile_options(HalideToolsRunGen PUBLIC "-fno-rtti")
endif()
4 changes: 0 additions & 4 deletions tutorial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ if (BUILD_AOT_TUTORIAL)
target_include_directories(lesson_10_aot_compilation_run PRIVATE "${FILTER_DIR}")
# Needed to find HalideBuffer.h
target_include_directories(lesson_10_aot_compilation_run PRIVATE "${CMAKE_BINARY_DIR}/include")
# HalideBuffer.h requires C++11
if (NOT MSVC)
target_compile_options(lesson_10_aot_compilation_run PUBLIC "-std=c++11")
endif()

if (NOT WIN32)
target_link_libraries(lesson_10_aot_compilation_run PRIVATE dl pthread)
Expand Down

0 comments on commit ed97f66

Please sign in to comment.