summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 903bcc4)
raw | patch | inline | side by side (parent: 903bcc4)
author | Oscar Fuentes <ofv@wanadoo.es> | |
Sat, 4 Apr 2009 22:41:07 +0000 (22:41 +0000) | ||
committer | Oscar Fuentes <ofv@wanadoo.es> | |
Sat, 4 Apr 2009 22:41:07 +0000 (22:41 +0000) |
of compiler parameters explicitly added by the build
specification. This macro replaces the cmake built-in
`add_definitions'.
Detects glibc and defines _GNU_SOURCE accordingly.
Resolves bug 3882.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68428 91177308-0d34-0410-b5e6-96231b3b80d8
specification. This macro replaces the cmake built-in
`add_definitions'.
Detects glibc and defines _GNU_SOURCE accordingly.
Resolves bug 3882.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68428 91177308-0d34-0410-b5e6-96231b3b80d8
CMakeLists.txt | patch | blob | history | |
cmake/config-ix.cmake | patch | blob | history | |
cmake/modules/AddLLVMDefinitions.cmake | [new file with mode: 0644] | patch | blob |
tools/llvm-config/CMakeLists.txt | patch | blob | history |
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1edea945c4b07f48f59ef6ad67afd70b3e6f2572..95f36a2bcd532fcbf42b728a5cdfbfbe4490e55b 100644 (file)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
"${LLVM_MAIN_SRC_DIR}/cmake/modules"
)
+include(AddLLVMDefinitions)
+
if(WIN32)
if(CYGWIN)
set(LLVM_ON_WIN32 0)
if( LLVM_ENABLE_PIC )
if( SUPPORTS_FPIC_FLAG )
message(STATUS "Building with -fPIC")
- add_definitions(-fPIC)
+ add_llvm_definitions(-fPIC)
else( SUPPORTS_FPIC_FLAG )
message(STATUS "Warning: -fPIC not supported.")
endif()
# set(CMAKE_VERBOSE_MAKEFILE true)
-add_definitions( -D__STDC_LIMIT_MACROS )
-add_definitions( -D__STDC_CONSTANT_MACROS )
+add_llvm_definitions( -D__STDC_LIMIT_MACROS )
+add_llvm_definitions( -D__STDC_CONSTANT_MACROS )
set(LLVM_PLO_FLAGS "" CACHE
STRING "Flags for creating partially linked objects.")
option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
if( LLVM_BUILD_32_BITS )
message(STATUS "Building 32 bits executables and libraries.")
- add_definitions( -m32 )
+ add_llvm_definitions( -m32 )
list(APPEND CMAKE_EXE_LINKER_FLAGS -m32)
list(APPEND CMAKE_SHARED_LINKER_FLAGS -m32)
set( LLVM_PLO_FLAGS -melf_i386 ${LLVM_PLO_FLAGS} )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
if( MSVC )
- add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS )
- add_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS )
- add_definitions( -D_SCL_SECURE_NO_DEPRECATE )
- add_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 )
- add_definitions( -wd4355 -wd4715 -wd4180 -wd4345 -wd4224 )
+ add_llvm_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS )
+ add_llvm_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS )
+ add_llvm_definitions( -D_SCL_SECURE_NO_DEPRECATE )
+ add_llvm_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 )
+ add_llvm_definitions( -wd4355 -wd4715 -wd4180 -wd4345 -wd4224 )
endif( MSVC )
include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR})
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index 9e5bcd8fe2667e0198631da6e64a628086c0bc2c..5ab3935f6de553f60fe488a1d97641d74c02e004 100755 (executable)
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
check_symbol_exists(pthread_mutex_lock pthread.h HAVE_PTHREAD_MUTEX_LOCK)
check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL)
+check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
+if( LLVM_USING_GLIBC )
+ add_llvm_definitions( -D_GNU_SOURCE )
+endif()
+
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fPIC" SUPPORTS_FPIC_FLAG)
diff --git a/cmake/modules/AddLLVMDefinitions.cmake b/cmake/modules/AddLLVMDefinitions.cmake
--- /dev/null
@@ -0,0 +1,11 @@
+# There is no clear way of keeping track of compiler command-line\r
+# options chosen via `add_definitions', so we need our own method for\r
+# using it on tools/llvm-config/CMakeLists.txt.\r
+\r
+# Beware that there is no implementation of remove_llvm_definitions.\r
+\r
+macro(add_llvm_definitions)\r
+ set(LLVM_DEFINITIONS "${LLVM_DEFINITIONS} ${ARGN}")\r
+ add_definitions( ${ARGN} )\r
+endmacro(add_llvm_definitions)\r
+\r
index 117589db134fea504a55727886aa1bd78fe0bccf..644ef964e6c5d26ebc43415451752185989688cc 100644 (file)
DEPENDS ${LIBDEPS}
COMMENT "Checking for cyclic dependencies between LLVM libraries.")
+string(TOUPPER ${CMAKE_BUILD_TYPE} uppercase_CMAKE_BUILD_TYPE)
+set(C_FLGS "${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
+set(CXX_FLGS "${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
+set(CPP_FLGS "${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
+
add_custom_command(OUTPUT ${LLVM_CONFIG}
- COMMAND echo 's!@LLVM_CPPFLAGS@!${CMAKE_CPP_FLAGS}!' > temp.sed
- COMMAND echo 's!@LLVM_CFLAGS@!${CMAKE_C_FLAGS}!' >> temp.sed
- COMMAND echo 's!@LLVM_CXXFLAGS@!${CMAKE_CXX_FLAGS}!' >> temp.sed
+ COMMAND echo 's!@LLVM_CPPFLAGS@!${CPP_FLGS}!' > temp.sed
+ COMMAND echo 's!@LLVM_CFLAGS@!${C_FLGS}!' >> temp.sed
+ COMMAND echo 's!@LLVM_CXXFLAGS@!${CXX_FLGS}!' >> temp.sed
# TODO: Use general flags for linking! not just for shared libs:
COMMAND echo 's!@LLVM_LDFLAGS@!${CMAKE_SHARED_LINKER_FLAGS}!' >> temp.sed
COMMAND echo 's!@LIBS@!!' >> temp.sed # TODO: System libs