From 47f7f0e34f7d31826575f2f3c97b32deaef2f3a6 Mon Sep 17 00:00:00 2001 From: Sergiy Kuryata Date: Thu, 17 Sep 2015 12:28:49 -0700 Subject: Make GC and GCSample compile and run on Linux :# Please enter the commit message for your changes. Lines starting --- src/Native/CMakeLists.txt | 72 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 8 deletions(-) (limited to 'src/Native/CMakeLists.txt') diff --git a/src/Native/CMakeLists.txt b/src/Native/CMakeLists.txt index 7d26d88fe..f3fc58549 100644 --- a/src/Native/CMakeLists.txt +++ b/src/Native/CMakeLists.txt @@ -8,14 +8,13 @@ set(CMAKE_C_FLAGS "-std=c11") set(CMAKE_CXX_FLAGS "-std=c++11") set(CMAKE_SHARED_LIBRARY_PREFIX "") -add_compile_options(-Weverything) -add_compile_options(-Wno-format-nonliteral) -add_compile_options(-Wno-missing-prototypes) -add_compile_options(-Wno-disabled-macro-expansion) -add_compile_options(-Wno-c++98-compat) -add_compile_options(-Wno-c++98-compat-pedantic) -add_compile_options(-Werror) -add_compile_options(-fPIC) +function(clr_unknown_arch) + if (WIN32) + message(FATAL_ERROR "Only AMD64 and I386 are supported") + else() + message(FATAL_ERROR "Only AMD64, ARM64 and ARM are supported") + endif() +endfunction() if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64) add_definitions(-DBIT64=1) @@ -28,10 +27,66 @@ elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l) add_compile_options(-mfpu=vfpv3) endif () +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + set(CLR_CMAKE_PLATFORM_UNIX 1) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) + set(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64 1) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l) + set(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM 1) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + set(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM64 1) + else() + clr_unknown_arch() + endif() + set(CLR_CMAKE_PLATFORM_LINUX 1) +endif(CMAKE_SYSTEM_NAME STREQUAL Linux) + +if (CLR_CMAKE_PLATFORM_UNIX) + add_definitions(-DPLATFORM_UNIX=1) + + # All warnings that are not explicitly disabled are reported as errors + add_compile_options(-Wall) + add_compile_options(-Werror) + + add_compile_options(-Wno-format-nonliteral) + add_compile_options(-Wno-missing-prototypes) + add_compile_options(-Wno-disabled-macro-expansion) + add_compile_options(-Wno-c++98-compat) + add_compile_options(-Wno-c++98-compat-pedantic) + + add_compile_options(-Wno-null-conversion) + add_compile_options(-Wno-invalid-offsetof) + add_compile_options(-Wno-null-arithmetic) + + # The -fms-extensions enable the stuff like __if_exists, __declspec(uuid()), etc. + add_compile_options(-fms-extensions ) + + add_compile_options(-fPIC) +endif(CLR_CMAKE_PLATFORM_UNIX) + +if(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM) + set(CLR_CMAKE_PLATFORM_ARCH_ARM 1) +elseif(CLR_CMAKE_PLATFORM_UNIX_TARGET_ARM64) + set(CLR_CMAKE_PLATFORM_ARCH_ARM64 1) +elseif(CLR_CMAKE_PLATFORM_UNIX_TARGET_AMD64) + set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1) +elseif(WIN32) + if (CLR_CMAKE_TARGET_ARCH STREQUAL x64) + set(CLR_CMAKE_PLATFORM_ARCH_AMD64 1) + set(IS_64BIT_BUILD 1) + elseif(CLR_CMAKE_TARGET_ARCH STREQUAL x86) + set(CLR_CMAKE_PLATFORM_ARCH_I386 1) + set(IS_64BIT_BUILD 0) + else() + clr_unknown_arch() + endif() +endif() + string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE) if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG) add_compile_options(-g -O0) add_definitions(-DDEBUG) + add_definitions(-D_DEBUG) elseif (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE) add_compile_options (-O3) add_definitions(-DNDEBUG) @@ -41,3 +96,4 @@ endif () include(configure.cmake) +add_subdirectory(gc) -- cgit v1.2.3