Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable some optimization flags in Release #360

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.9)

set(H3_PREFIX "" CACHE STRING "Prefix for exported symbols")
set(H3_ALLOC_PREFIX "" CACHE STRING "Prefix for allocation functions")
Expand All @@ -23,6 +23,9 @@ set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# YCM needs compilation database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Interprocedural optimization
cmake_policy(SET CMP0069 NEW)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain.cmake"
Expand Down Expand Up @@ -65,6 +68,7 @@ if(NOT WIN32)
# are not correct for MSVC.
list(APPEND H3_COMPILE_FLAGS -Wall)

list(APPEND H3_COMPILE_FLAGS $<$<CONFIG:Release>:-O2 -finline-functions>)
list(APPEND H3_COMPILE_FLAGS $<$<CONFIG:Debug>:-gdwarf-2 -g3 -O0 -fno-inline -fno-eliminate-unused-debug-types>)

if(ENABLE_COVERAGE)
Expand Down Expand Up @@ -274,17 +278,17 @@ elseif(NOT CLANG_FORMAT_PATH)
"so automatic source code reformatting is disabled")
endif()

option(ENABLE_LINTING "Run clang-tidy on source files" ON)
find_program(CLANG_TIDY_PATH "clang-tidy")
cmake_dependent_option(
ENABLE_LINTING "Enable running clang-tidy on sources during compilation" ON
"CLANG_TIDY_PATH" OFF)
if(ENABLE_LINTING)
set_target_properties(h3 PROPERTIES C_CLANG_TIDY "${CLANG_TIDY_PATH}")
elseif(NOT CLANG_TIDY_PATH)
message(WARNING "clang-tidy was not detected, "
"so source code linting is disabled")
endif()
# option(ENABLE_LINTING "Run clang-tidy on source files" ON)
# find_program(CLANG_TIDY_PATH "clang-tidy")
# cmake_dependent_option(
# ENABLE_LINTING "Enable running clang-tidy on sources during compilation" ON
# "CLANG_TIDY_PATH" OFF)
# if(ENABLE_LINTING)
# set_target_properties(h3 PROPERTIES C_CLANG_TIDY "${CLANG_TIDY_PATH}")
# elseif(NOT CLANG_TIDY_PATH)
# message(WARNING "clang-tidy was not detected, "
# "so source code linting is disabled")
# endif()

# Docs
find_package(Doxygen)
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.1)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)

project(h3examples)
project(h3examples LANGUAGES C)

find_package(h3 CONFIG REQUIRED)

Expand Down