Skip to content

Commit

Permalink
Add "-fvisibility-inlines-hidden" to CMAKE_CXX_FLAGS.
Browse files Browse the repository at this point in the history
Use the same logic that LLVM uses for including this flag in the C++
command-line options.

Without this, I get a bunch of link-time warnings when I build C-Reduce
against the precompiled OS X binary for LLVM 3.8.0.
  • Loading branch information
eeide committed Jun 2, 2016
1 parent 5c0332e commit 384aa74
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions CMakeLists.txt
Expand Up @@ -12,6 +12,7 @@ cmake_minimum_required(VERSION 2.8.12)
project(creduce)

include(CheckIncludeFile)
include(CheckCXXCompilerFlag)

###############################################################################

Expand Down Expand Up @@ -49,13 +50,27 @@ configure_file("cmake_config.h.in" "${PROJECT_BINARY_DIR}/config.h")
execute_process(COMMAND "git" "show" "-s" "--format=%h" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE creduce_GIT_HASH)
string(STRIP "${creduce_GIT_HASH}" creduce_GIT_HASH)

###

# Include this flag if the C++ compiler supports it.
# See LLVM file `share/llvm/cmake/HandleLLVMOptions.cmake`.
check_cxx_compiler_flag(
"-fvisibility-inlines-hidden"
SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# XXX figure out how to get "-std=c++11 -fno-rtti" from LLVM. That's how we
# get those options in the Automake path...
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-strict-aliasing -Wall -Wextra -Wno-long-long -Wno-unused-parameter -Wno-missing-field-initializers")
if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
endif()

###

add_subdirectory(clang_delta)
add_subdirectory(clex)
add_subdirectory(creduce)
Expand Down

0 comments on commit 384aa74

Please sign in to comment.