[llvm-commits] [llvm] r68428 - in /llvm/trunk: CMakeLists.txt cmake/config-ix.cmake cmake/modules/AddLLVMDefinitions.cmake tools/llvm-config/CMakeLists.txt
Oscar Fuentes
ofv at wanadoo.es
Sat Apr 4 15:41:07 PDT 2009
Author: ofv
Date: Sat Apr 4 17:41:07 2009
New Revision: 68428
URL: http://llvm.org/viewvc/llvm-project?rev=68428&view=rev
Log:
CMake: defines and uses macro add_llvm_definitions for keeping track
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.
Added:
llvm/trunk/cmake/modules/AddLLVMDefinitions.cmake
Modified:
llvm/trunk/CMakeLists.txt
llvm/trunk/cmake/config-ix.cmake
llvm/trunk/tools/llvm-config/CMakeLists.txt
Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=68428&r1=68427&r2=68428&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Sat Apr 4 17:41:07 2009
@@ -74,6 +74,8 @@
"${LLVM_MAIN_SRC_DIR}/cmake/modules"
)
+include(AddLLVMDefinitions)
+
if(WIN32)
if(CYGWIN)
set(LLVM_ON_WIN32 0)
@@ -110,7 +112,7 @@
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()
@@ -122,8 +124,8 @@
# 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.")
@@ -133,7 +135,7 @@
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} )
@@ -141,11 +143,11 @@
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})
Modified: llvm/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=68428&r1=68427&r2=68428&view=diff
==============================================================================
--- llvm/trunk/cmake/config-ix.cmake (original)
+++ llvm/trunk/cmake/config-ix.cmake Sat Apr 4 17:41:07 2009
@@ -52,6 +52,11 @@
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)
Added: llvm/trunk/cmake/modules/AddLLVMDefinitions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVMDefinitions.cmake?rev=68428&view=auto
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVMDefinitions.cmake (added)
+++ llvm/trunk/cmake/modules/AddLLVMDefinitions.cmake Sat Apr 4 17:41:07 2009
@@ -0,0 +1,11 @@
+# There is no clear way of keeping track of compiler command-line
+# options chosen via `add_definitions', so we need our own method for
+# using it on tools/llvm-config/CMakeLists.txt.
+
+# Beware that there is no implementation of remove_llvm_definitions.
+
+macro(add_llvm_definitions)
+ set(LLVM_DEFINITIONS "${LLVM_DEFINITIONS} ${ARGN}")
+ add_definitions( ${ARGN} )
+endmacro(add_llvm_definitions)
+
Modified: llvm/trunk/tools/llvm-config/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/CMakeLists.txt?rev=68428&r1=68427&r2=68428&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-config/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-config/CMakeLists.txt Sat Apr 4 17:41:07 2009
@@ -82,10 +82,15 @@
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
More information about the llvm-commits
mailing list