[CMAKE]
authorJérôme Gardou <jerome.gardou@reactos.org>
Sat, 3 Sep 2011 23:05:09 +0000 (23:05 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Sat, 3 Sep 2011 23:05:09 +0000 (23:05 +0000)
- add flags to ASM as well instead of hacking the compile rule
- remove -fPIC flag from ASM compile flags, (it's a cmake bug)
- enable languages before including compiler specific files.

svn path=/trunk/; revision=53567

reactos/CMakeLists.txt
reactos/cmake/compilerflags.cmake
reactos/cmake/gcc.cmake

index f96d129..81658b6 100644 (file)
@@ -137,6 +137,12 @@ else()
     elseif(ARCH MATCHES arm)
         add_definitions(-DUSE_COMPILER_EXCEPTIONS)
     endif()
+    
+    # Activate support for assembly source files
+    enable_language(ASM)
+
+    # Activate language support for resource files
+    enable_language(RC)
 
     # Compiler specific definitions and macros
     if(MSVC)
@@ -151,12 +157,6 @@ else()
     # IDL macros for widl/midl
     include(cmake/idl-support.cmake)
 
-    # Activate support for assembly source files
-    enable_language(ASM)
-
-    # Activate language support for resource files
-    enable_language(RC)
-
     if(MSVC AND USE_WDK_HEADERS)
         include_directories(
             include
index 4c56b99..01501d0 100644 (file)
@@ -43,6 +43,7 @@ function(add_compile_flags _flags)
     # Adds the compiler flag to both CMAKE_C_FLAGS and CMAKE_CXX_FLAGS
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flags}" PARENT_SCOPE)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flags}" PARENT_SCOPE)
+    set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${_flags}" PARENT_SCOPE)
 endfunction()
 
 function(add_target_compile_flags _module _flags)
index 51558c5..4149b5d 100644 (file)
@@ -5,6 +5,9 @@ add_compile_flags("-pipe -fms-extensions")
 # Debugging (Note: DWARF-4 on 4.5.1 when we ship)
 add_compile_flags("-gdwarf-2 -g2 -femit-struct-debug-detailed=none -feliminate-unused-debug-types")
 
+# For some reason, cmake sets -fPIC, and we don't want it
+string(REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_ASM_FLAGS ${CMAKE_SHARED_LIBRARY_ASM_FLAGS})
+
 # Tuning
 if(ARCH MATCHES i386)
     add_compile_flags("-march=${OARCH} -mtune=${TUNE}")
@@ -13,7 +16,7 @@ else()
 endif()
 
 # Warnings
-add_compile_flags("-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value -Winvalid-pch")
+add_compile_flags("-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar -Wno-error=uninitialized -Wno-unused-value")
 
 if(ARCH MATCHES amd64)
     add_compile_flags("-Wno-format")
@@ -86,7 +89,7 @@ set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FL
 set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
 set(CMAKE_RC_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
 
-set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -x assembler-with-cpp -o <OBJECT> -I${REACTOS_SOURCE_DIR}/include/asm -I${REACTOS_BINARY_DIR}/include/asm <FLAGS> ${CMAKE_C_FLAGS} <DEFINES> -D__ASM__ -c <SOURCE>")
+set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -x assembler-with-cpp -o <OBJECT> -I${REACTOS_SOURCE_DIR}/include/asm -I${REACTOS_BINARY_DIR}/include/asm <FLAGS> <DEFINES> -D__ASM__ -c <SOURCE>")
 
 #set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -i <SOURCE> <CMAKE_C_LINK_FLAGS> <DEFINES> -I${REACTOS_SOURCE_DIR}/include/psdk -I${REACTOS_BINARY_DIR}/include/psdk -I${REACTOS_SOURCE_DIR}/include/ -I${REACTOS_SOURCE_DIR}/include/reactos -I${REACTOS_BINARY_DIR}/include/reactos -I${REACTOS_SOURCE_DIR}/include/reactos/wine -I${REACTOS_SOURCE_DIR}/include/crt -I${REACTOS_SOURCE_DIR}/include/crt/mingw32 -O coff -o <OBJECT>")
 
@@ -295,12 +298,7 @@ if(PCH)
             IMPLICIT_DEPENDS ${__lang} ${_header_filename}
             DEPENDS ${_header_filename} ${ARGN})
         get_target_property(_src_files ${_target_name} SOURCES)
-        foreach(_item in ${_src_files})
-            get_source_file_property(__src_lang ${_item} LANGUAGE)
-            if(__src_lang STREQUAL __lang)
-                set_source_files_properties(${_item} PROPERTIES COMPILE_FLAGS "-fpch-preprocess" OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_gch_filename})
-            endif()
-        endforeach()
+        add_target_compile_flags(${_target_name} "-fpch-preprocess -Winvalid-pch -Wno-error=invalid-pch")
         #set dependency checking : depends on precompiled header only which already depends on deeper header
         set_target_properties(${_target_name} PROPERTIES IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "\"${_basename}\"=;<${_basename}>=")
     endmacro()