diff options
-rw-r--r-- | src/Native/CMakeLists.txt | 72 | ||||
-rw-r--r-- | src/Native/gc/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/Native/gc/sample/CMakeLists.txt | 3 |
3 files changed, 71 insertions, 8 deletions
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) diff --git a/src/Native/gc/CMakeLists.txt b/src/Native/gc/CMakeLists.txt index 990d8e611..1bd54109b 100644 --- a/src/Native/gc/CMakeLists.txt +++ b/src/Native/gc/CMakeLists.txt @@ -47,3 +47,7 @@ add_compile_options(-Wno-tautological-undefined-compare) add_library(clrgc STATIC ${SOURCES}) +# Install the static clrgc library +install (TARGETS clrgc DESTINATION lib) + +add_subdirectory(sample) diff --git a/src/Native/gc/sample/CMakeLists.txt b/src/Native/gc/sample/CMakeLists.txt index 5dc301412..bfe573d82 100644 --- a/src/Native/gc/sample/CMakeLists.txt +++ b/src/Native/gc/sample/CMakeLists.txt @@ -30,3 +30,6 @@ endif() target_link_libraries(gcsample clrgc ) + +# Install gcsample +install (TARGETS gcsample DESTINATION .) |