Author: akhaldi
Date: Sun Jan 9 16:49:10 2011
New Revision: 50340
URL:
http://svn.reactos.org/svn/reactos?rev=50340&view=rev
Log:
[CMAKE]
- Improve the warnings and compiler flags according to the different architectures we
have.
Modified:
branches/cmake-bringup/config.cmake
branches/cmake-bringup/gcc.cmake
branches/cmake-bringup/msc.cmake
Modified: branches/cmake-bringup/config.cmake
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/config.cmake?rev=…
==============================================================================
--- branches/cmake-bringup/config.cmake [iso-8859-1] (original)
+++ branches/cmake-bringup/config.cmake [iso-8859-1] Sun Jan 9 16:49:10 2011
@@ -12,7 +12,7 @@
set(TUNE "i686" CACHE STRING
"Which CPU ReactOS should be optimized for.")
-set (OPTIMIZE "1" CACHE STRING
+set(OPTIMIZE "1" CACHE STRING
"What level of optimisation to use.
0 = off
1 = Default option, optimize for size (-Os) with some additional options
Modified: branches/cmake-bringup/gcc.cmake
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/gcc.cmake?rev=503…
==============================================================================
--- branches/cmake-bringup/gcc.cmake [iso-8859-1] (original)
+++ branches/cmake-bringup/gcc.cmake [iso-8859-1] Sun Jan 9 16:49:10 2011
@@ -27,18 +27,53 @@
endif()
# Warnings
+
add_definitions(-Wall -Wno-char-subscripts -Wpointer-arith -Wno-multichar
-Wno-error=uninitialized -Wno-unused-value -Winvalid-pch)
+if(ARCH MATCHES amd64)
+ add_definitions(-Wno-format)
+elseif(ARCH MATCHES arm)
+ add_definitions(-Wno-attributes)
+endif()
+
# Optimizations
+
+if(OPTIMIZE STREQUAL "1")
+ add_definitions(-Os)
+elseif(OPTIMIZE STREQUAL "2")
+ add_definitions(-Os)
+elseif(OPTIMIZE STREQUAL "3")
+ add_definitions(-O1)
+elseif(OPTIMIZE STREQUAL "4")
+ add_definitions(-O2)
+elseif(OPTIMIZE STREQUAL "5")
+ add_definitions(-O3)
+endif()
+
+add_definitions(-fno-strict-aliasing)
+
if(ARCH MATCHES i386)
- add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer
-mpreferred-stack-boundary=2 -fno-set-stack-executable -fno-optimize-sibling-calls)
+ add_definitions(-mpreferred-stack-boundary=2 -fno-set-stack-executable
-fno-optimize-sibling-calls)
+ if(OPTIMIZE STREQUAL "1")
+ add_definitions(-ftracer -momit-leaf-frame-pointer)
+ endif()
elseif(ARCH MATCHES amd64)
- add_definitions(-Os -fno-strict-aliasing -ftracer -momit-leaf-frame-pointer
-mpreferred-stack-boundary=4)
+ add_definitions(-mpreferred-stack-boundary=4)
+ if(OPTIMIZE STREQUAL "1")
+ add_definitions(-ftracer -momit-leaf-frame-pointer)
+ endif()
+elseif(ARCH MATCHES arm)
+ if(OPTIMIZE STREQUAL "1")
+ add_definitions(-ftracer)
+ endif()
endif()
# Other
if(ARCH MATCHES amd64)
-add_definitions(-U_X86_ -UWIN32)
+ add_definitions(-U_X86_ -UWIN32)
+elseif(ARCH MATCHES arm)
+ add_definitions(-U_UNICODE -UUNICODE)
+ add_definitions(-D__MSVCRT__) # DUBIOUS
endif()
# alternative arch name
@@ -280,4 +315,4 @@
#pseh lib, needed with mingw
set(PSEH_LIB "pseh")
-endif()
+endif(CMAKE_CROSSCOMPILING)
Modified: branches/cmake-bringup/msc.cmake
URL:
http://svn.reactos.org/svn/reactos/branches/cmake-bringup/msc.cmake?rev=503…
==============================================================================
--- branches/cmake-bringup/msc.cmake [iso-8859-1] (original)
+++ branches/cmake-bringup/msc.cmake [iso-8859-1] Sun Jan 9 16:49:10 2011
@@ -5,31 +5,41 @@
add_definitions(-Dinline=__inline)
-if(NOT CMAKE_CROSSCOMPILING)
-
-else()
+if(CMAKE_CROSSCOMPILING)
+
+if(OPTIMIZE STREQUAL "1")
+ add_definitions(/O1)
+elseif(OPTIMIZE STREQUAL "2")
+ add_definitions(/O2)
+elseif(OPTIMIZE STREQUAL "3")
+ add_definitions(/Ot /Ox /GS-)
+elseif(OPTIMIZE STREQUAL "4")
+ add_definitions(/Os /Ox /GS-)
+elseif(OPTIMIZE STREQUAL "5")
+ add_definitions(/GF /Gy /Ob2 /Os /Ox /GS-)
+endif()
add_definitions(/GS- /Zl /Zi)
add_definitions(-Dinline=__inline -D__STDC__=1)
-IF(${_MACHINE_ARCH_FLAG} MATCHES X86)
- SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
- SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
- SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
-ENDIF()
+if(${_MACHINE_ARCH_FLAG} MATCHES X86)
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
+endif()
link_directories("${REACTOS_BINARY_DIR}/importlibs"
${REACTOS_BINARY_DIR}/lib/3rdparty/mingw)
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>")
-MACRO(add_pch _target_name _header_filename _src_list)
+macro(add_pch _target_name _header_filename _src_list)
get_filename_component(FILE ${_header_filename} NAME)
set(_gch_filename "${_target_name}_${FILE}.gch")
add_custom_command(
OUTPUT ${_gch_filename}
COMMAND echo Ignoring precompiled header
DEPENDS ${_header_filename})
-ENDMACRO(add_pch _target_name _header_filename _src_list)
+endmacro()
macro(add_linkerflag MODULE _flag)
set(NEW_LINKER_FLAGS ${_flag})
@@ -70,7 +80,7 @@
else()
target_link_libraries(${MODULE} mingw_main)
endif()
- target_link_libraries(${MODULE} mingw_common msvcsup)
+ target_link_libraries(${MODULE} mingw_common msvcsup)
endif ()
if (${TYPE} MATCHES win32cui)
set_subsystem(${MODULE} console)
@@ -80,17 +90,17 @@
else()
target_link_libraries(${MODULE} mingw_main)
endif()
- target_link_libraries(${MODULE} mingw_common msvcsup)
+ target_link_libraries(${MODULE} mingw_common msvcsup)
endif ()
if(${TYPE} MATCHES win32dll)
# Need this only because mingw library is broken
set_entrypoint(${MODULE} DllMainCRTStartup@12)
- if(DEFINED baseaddress_${MODULE})
- set_image_base(${MODULE} ${baseaddress_${MODULE}})
- else()
- message(STATUS "${MODULE} has no base address")
- endif()
- target_link_libraries(${MODULE} mingw_common mingw_dllmain msvcsup)
+ if(DEFINED baseaddress_${MODULE})
+ set_image_base(${MODULE} ${baseaddress_${MODULE}})
+ else()
+ message(STATUS "${MODULE} has no base address")
+ endif()
+ target_link_libraries(${MODULE} mingw_common mingw_dllmain msvcsup)
add_linkerflag(${MODULE} "/DLL")
endif()
if(${TYPE} MATCHES win32ocx)
@@ -105,15 +115,14 @@
target_link_libraries(${MODULE} mingw_common mingw_dllmain msvcsup)
add_linkerflag(${MODULE} "/DLL")
endif()
- if(${TYPE} MATCHES kernelmodedriver)
- set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
- set_entrypoint(${MODULE} DriverEntry@8)
- set_subsystem(${MODULE} native)
+ if(${TYPE} MATCHES kernelmodedriver)
+ set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
+ set_entrypoint(${MODULE} DriverEntry@8)
+ set_subsystem(${MODULE} native)
set_image_base(${MODULE} 0x00010000)
add_linkerflag(${MODULE} "/DRIVER")
- add_dependencies(${MODULE} bugcodes)
- endif()
-
+ add_dependencies(${MODULE} bugcodes)
+ endif()
endmacro()
macro(set_unicode)
@@ -213,4 +222,4 @@
#pseh workaround
set(PSEH_LIB "")
-endif()
+endif(CMAKE_CROSSCOMPILING)