Merge pull request #3535 from hughbe/patch-3
[platform/upstream/coreclr.git] / tests / CMakeLists.txt
1 # Require at least version 2.8.12 of CMake
2 cmake_minimum_required(VERSION 2.8.12)
3
4 if (CMAKE_CONFIGURATION_TYPES) # multi-configuration generator?
5     set(CMAKE_CONFIGURATION_TYPES "Debug;Checked;Release;RelWithDebInfo" CACHE STRING "" FORCE)
6 endif (CMAKE_CONFIGURATION_TYPES)
7 set(CMAKE_C_FLAGS_CHECKED "")
8 set(CMAKE_CXX_FLAGS_CHECKED "")
9 set(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
10 set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
11
12 set(INC_PLATFORM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Common/Platform)
13 if (WIN32)
14     add_definitions(-DWINDOWS=1)
15
16     if (DEFINED ENV{__ToolsetDir})
17         # Hack for private Tool Set
18         # CMAKE_CXX_COMPILER will default to the compiler installed with
19         # Visual studio. Overwrite it to the compiler on the path.
20
21         find_program(PATH_CXX_COMPILER cl)
22         set(CMAKE_CXX_COMPILER ${PATH_CXX_COMPILER})
23
24         message("Overwriting the CMAKE_CXX_COMPILER.")
25         message("CMAKE_CXX_COMPILER found:${CMAKE_CXX_COMPILER}")
26       
27         # Temporary until cmake has VS generators for hacky toolsets [arm64]
28         set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
29         set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
30         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
31     endif()
32 endif()
33
34 # Compile options
35
36 if (WIN32)
37     add_compile_options(-wd4100 -wd4514 -wd4668 -wd4710 -wd4711 -wd4820)
38 endif()
39
40 if(CLR_CMAKE_PLATFORM_UNIX)
41     add_compile_options(-fPIC)
42 endif(CLR_CMAKE_PLATFORM_UNIX)
43
44 MACRO(SUBDIRLIST result curdir)
45   FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
46   SET(dirlist "")
47   FOREACH(child ${children})
48     IF(IS_DIRECTORY ${curdir}/${child})
49         LIST(APPEND dirlist ${child})
50     ENDIF()
51   ENDFOREACH()
52   SET(${result} ${dirlist})
53 ENDMACRO()
54
55 MACRO(ADDSUBDIR_REC  curdir)
56     SUBDIRLIST(SUB_DIRS ${curdir})
57     FOREACH(subdir ${SUB_DIRS})
58         if(EXISTS "${curdir}/${subdir}/CMakeLists.txt")
59            ADD_SUBDIRECTORY(${curdir}/${subdir})
60         else()
61            ADDSUBDIR_REC(${curdir}/${subdir})
62         endif(EXISTS "${curdir}/${subdir}/CMakeLists.txt")
63     ENDFOREACH()
64 ENDMACRO()
65
66 ADDSUBDIR_REC(${CMAKE_CURRENT_SOURCE_DIR})