[CMAKE]: Disable standard C libraries (WIP: Should add libgcc).
authorSir Richard <sir_richard@svn.reactos.org>
Wed, 4 Aug 2010 14:29:24 +0000 (14:29 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Wed, 4 Aug 2010 14:29:24 +0000 (14:29 +0000)
[CMAKE]: Set global linker flags we need for all libraries.
[CMAKE]: Set specific NTDLL linker flag.
Thanks to Amine for some of his help.

svn path=/branches/cmake-bringup/; revision=48457

dll/ntdll/CMakeLists.txt
toolchain-mingw32.cmake

index e2b7908..0b872a0 100644 (file)
@@ -1,7 +1,3 @@
-
-SET(CMAKE_C_CREATE_SHARED_LIBRARY
-  "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -Wl,--enable-stdcall-fixup -Wl,--kill-at -o <TARGET> <OBJECTS> ${CMAKE_CURRENT_SOURCE_DIR}/def/ntdll.def <LINK_LIBRARIES>")
-
 add_definitions(-D__NTDLL__)
 add_definitions(-D_NTOSKRNL_)
 add_definitions(-DCRTDLL)
@@ -10,12 +6,26 @@ include_directories(BEFORE ./include)
 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/subsys)
 
 file(GLOB_RECURSE SOURCE *.c)
-list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/ldr/elf.c ${CMAKE_CURRENT_SOURCE_DIR}/dispatch/dispatch.c)
-list(REMOVE_ITEM SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/dispatch/amd64/stubs.c)
+list(REMOVE_ITEM SOURCE
+     ${CMAKE_CURRENT_SOURCE_DIR}/ldr/elf.c
+     ${CMAKE_CURRENT_SOURCE_DIR}/dispatch/dispatch.c
+     ${CMAKE_CURRENT_SOURCE_DIR}/dispatch/amd64/stubs.c)
+file(GLOB_RECURSE ARCH_SOURCE
+    "${CMAKE_CURRENT_SOURCE_DIR}/dispatch/${ARCH}/*.c"
+    "${CMAKE_CURRENT_SOURCE_DIR}/dispatch/${ARCH}/*.s")
+
+add_library(ntdll SHARED
+            ${ARCH_SOURCE} ${SOURCE}
+            ${CMAKE_CURRENT_SOURCE_DIR}/def/ntdll.rc
+            ${CMAKE_CURRENT_SOURCE_DIR}/include/ntdll.h.gch)
 
-file(GLOB_RECURSE ARCH_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/dispatch/${ARCH}/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/dispatch/${ARCH}/*.s")
+set_target_properties(ntdll PROPERTIES LINK_FLAGS "-Wl,-entry,0")
 
-add_library(ntdll SHARED ${ARCH_SOURCE} ${SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/def/ntdll.rc  ${CMAKE_CURRENT_SOURCE_DIR}/include/ntdll.h.gch)
-target_link_libraries(ntdll rtl ntdllsys libcntpr pseh)
+target_link_libraries(ntdll ${CMAKE_CURRENT_SOURCE_DIR}/def/ntdll.def
+                      rtl 
+                      ntdllsys
+                      libcntpr
+                      pseh)
+                      
 add_pch(ntdll ${CMAKE_CURRENT_SOURCE_DIR}/include/ntdll.h ${SOURCE})
-add_dependencies(ntdll ntstatus version)
\ No newline at end of file
+add_dependencies(ntdll ntstatus version)
index abbc90f..4f4b7aa 100644 (file)
@@ -20,6 +20,10 @@ SET(CMAKE_ASM_COMPILER ${MINGW_PREFIX}gcc)
 SET(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -x assembler-with-cpp -o <OBJECT> <FLAGS> <DEFINES> -D__ASM__ -c <SOURCE>")
 SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -I${REACTOS_SOURCE_DIR}/include/ -I${REACTOS_BINARY_DIR}/include/reactos -i <SOURCE> -o <OBJECT> <DEFINES> -DRC_INVOKED")
 
+# Use stdcall fixups, and don't link with anything by default unless we say so
+set(CMAKE_C_STANDARD_LIBRARIES "") # We should add the environment libgcc here
+SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-stdcall-fixup -Wl,--kill-at -nodefaultlibs -nostdlib")
+
 # adjust the default behaviour of the FIND_XXX() commands:
 # search headers and libraries in the target environment, search 
 # programs in the host environment