Skip to content
Permalink
Browse files

formatted according root CMakeLists.txt and missing thirdparty CMakeL…

…ists.txt
  • Loading branch information
Philipp Hoch
Philipp Hoch committed Jul 5, 2019
1 parent 159e97d commit 240756dc98dae9e446813a9746f6bf3c0e57a383
@@ -1,119 +1,135 @@
cmake_minimum_required(VERSION 2.8.7)
#if(APPLE) # needs to be before project()
# SET(CMAKE_CXX_FLAGS -stdlib=libc++)
# SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Minimum OS X deployment version")
#endif()
# if(APPLE) # needs to be before project() SET(CMAKE_CXX_FLAGS -stdlib=libc++)
# SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Minimum OS X deployment
# version") endif()

project(DuckDB)

find_package(Threads REQUIRED)


SET(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

SET(CMAKE_VERBOSE_MAKEFILE OFF)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(CMAKE_MACOSX_RPATH 1)

SET(M32_FLAG "")
IF (FORCE_32_BIT)
SET(M32_FLAG " -m32 ")
ENDIF()

option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)
if (${FORCE_COLORED_OUTPUT})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
endif ()

option (ENABLE_SANITIZER "Enable sanitizer." TRUE)
if (${ENABLE_SANITIZER})
SET(CXX_EXTRA_DEBUG "${CXX_EXTRA_DEBUG} -fsanitize=address")
endif ()

IF(NOT MSVC)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -DDEBUG -Wall ${M32_FLAG}")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG ${M32_FLAG}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")

SET(CXX_EXTRA_DEBUG "${CXX_EXTRA_DEBUG} -Wunused-variable -Wunused-const-variable -Werror=vla -Wnarrowing")

IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CXX_EXTRA_DEBUG}")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CXX_EXTRA_DEBUG}")
ELSE()
message(WARNING "Please use a recent compiler for debug builds")
ENDIF()
ELSE()
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4244") # equivalent to -Wnarrowing
ENDIF()

set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_MACOSX_RPATH 1)

set(M32_FLAG "")
if(FORCE_32_BIT)
set(M32_FLAG " -m32 ")
endif()

option(FORCE_COLORED_OUTPUT
"Always produce ANSI-colored output (GNU/Clang only)." FALSE)
if(${FORCE_COLORED_OUTPUT})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()

option(ENABLE_SANITIZER "Enable sanitizer." TRUE)
if(${ENABLE_SANITIZER})
set(CXX_EXTRA_DEBUG "${CXX_EXTRA_DEBUG} -fsanitize=address")
endif()

if(NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -DDEBUG -Wall ${M32_FLAG}")
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG ${M32_FLAG}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")

set(
CXX_EXTRA_DEBUG
"${CXX_EXTRA_DEBUG} -Wunused-variable -Wunused-const-variable -Werror=vla -Wnarrowing"
)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CXX_EXTRA_DEBUG}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CXX_EXTRA_DEBUG}")
else()
message(WARNING "Please use a recent compiler for debug builds")
endif()
else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4244") # equivalent to
# -Wnarrowing
endif()

# todo use CHECK_CXX_COMPILER_FLAG(-fsanitize=address SUPPORTS_SANITIZER) etc.

SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")

IF (NOT CMAKE_BUILD_TYPE)
message(FATAL_ERROR "Choose the type of build by setting -DCMAKE_BUILD_TYPE=<type>, options are: Debug Release")
ENDIF()
if(NOT CMAKE_BUILD_TYPE)
message(
FATAL_ERROR
"Choose the type of build by setting -DCMAKE_BUILD_TYPE=<type>, options are: Debug Release"
)
endif()

include_directories(src/include)
include_directories(third_party/hyperloglog)
include_directories(third_party/re2)
include_directories(third_party/miniz)

# todo only regenerate ub file if one of the input files changed
# hack alert
# todo only regenerate ub file if one of the input files changed hack alert
function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
set(files ${${SOURCE_VARIABLE_NAME}})

# Generate a unique filename for the unity build translation unit
set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp)
# Exclude all translation units from compilation
set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true)

SET(rebuild FALSE)
foreach(source_file ${files} )
if(${CMAKE_CURRENT_SOURCE_DIR}/${source_file} IS_NEWER_THAN ${unit_build_file})
SET(rebuild TRUE)
endif()
set_source_files_properties(${files}
PROPERTIES
HEADER_FILE_ONLY
true)

set(rebuild FALSE)
foreach(source_file ${files})
if(${CMAKE_CURRENT_SOURCE_DIR}/${source_file} IS_NEWER_THAN
${unit_build_file})
set(rebuild TRUE)
endif()
endforeach(source_file)

if (${rebuild})
FILE(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
foreach(source_file ${files} )
FILE( APPEND ${unit_build_file} "#line 0 \"${source_file}\"\n#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n")
endforeach(source_file)
if(${rebuild})
file(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
foreach(source_file ${files})
file(
APPEND ${unit_build_file}
"#line 0 \"${source_file}\"\n#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n"
)
endforeach(source_file)
endif()

# Complement list of translation units with the name of ub
set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE)
set(${SOURCE_VARIABLE_NAME}
${${SOURCE_VARIABLE_NAME}} ${unit_build_file}
PARENT_SCOPE)
endfunction(enable_unity_build)

function(add_library_unity NAME MODE)
SET(SRCS ${ARGN})
if (NOT DISABLE_UNITY)
enable_unity_build(${NAME} SRCS)
endif()
set(SRCS ${ARGN})
if(NOT DISABLE_UNITY)
enable_unity_build(${NAME} SRCS)
endif()
add_library(${NAME} OBJECT ${SRCS})
endfunction()


add_subdirectory(src)
add_subdirectory(third_party)

IF (NOT LEAN)
add_subdirectory(test)
IF (NOT WIN32)
add_subdirectory(tools)
add_subdirectory(benchmark)
ENDIF()
ENDIF()
if(NOT LEAN)
add_subdirectory(test)
if(NOT WIN32)
add_subdirectory(tools)
add_subdirectory(benchmark)
endif()
endif()
@@ -6,10 +6,10 @@ add_subdirectory(libpg_query)
add_subdirectory(re2)
add_subdirectory(miniz)

IF (NOT WIN32 AND NOT LEAN)
if(NOT WIN32 AND NOT LEAN)
add_subdirectory(dbgen)
add_subdirectory(dsdgen)
add_subdirectory(sqlsmith)
add_subdirectory(sqlite)
add_subdirectory(tpce-tool)
ENDIF()
endif()
@@ -1,2 +1,2 @@
CMAKE_POLICY(SET CMP0063 NEW)
cmake_policy(SET CMP0063 NEW)
add_library(hyperloglog STATIC hyperloglog.c sds.c)
@@ -1,19 +1,31 @@
cmake_minimum_required(VERSION 2.8.7)

project(pg_query CXX C)
CMAKE_POLICY(SET CMP0063 NEW)
cmake_policy(SET CMP0063 NEW)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)

# this code imitates the Makefile in /third_party/libpg_query/
file(GLOB_RECURSE pg_query_srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.c)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

add_library(pg_query STATIC postgres_parser.cpp pg_functions.cpp src_backend_parser_parser.c src_backend_parser_gram.c src_backend_nodes_list.c src_backend_parser_scansup.c src_backend_nodes_makefuncs.c src_backend_nodes_value.c src_backend_parser_scan.c src_common_keywords.c)
add_library(pg_query STATIC
postgres_parser.cpp
pg_functions.cpp
src_backend_parser_parser.c
src_backend_parser_gram.c
src_backend_nodes_list.c
src_backend_parser_scansup.c
src_backend_nodes_makefuncs.c
src_backend_nodes_value.c
src_backend_parser_scan.c
src_common_keywords.c)

IF (NOT MSVC)
set_target_properties(pg_query PROPERTIES COMPILE_FLAGS "-Wno-unused-function -Wno-unused-variable")
ENDIF()
if(NOT MSVC)
set_target_properties(pg_query
PROPERTIES COMPILE_FLAGS
"-Wno-unused-function -Wno-unused-variable")
endif()

set_target_properties(pg_query PROPERTIES LINKER_LANGUAGE C)
set_target_properties(pg_query PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(pg_query PROPERTIES POSITION_INDEPENDENT_CODE ON)
@@ -1,4 +1,4 @@
CMAKE_POLICY(SET CMP0063 NEW)
cmake_policy(SET CMP0063 NEW)

add_definitions(-DMINIZ_NO_ARCHIVE_APIS)
add_library(miniz STATIC miniz.c)

0 comments on commit 240756d

Please sign in to comment.
You can’t perform that action at this time.