summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/exception_handling/pal_sxs/test1/CMakeLists.txt
blob: 4a3abc2d640ef44de8a531cf19f324ad9040e992 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
cmake_minimum_required(VERSION 2.8.12.2)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(CLR_CMAKE_PLATFORM_UNIX)
    add_compile_options(-fPIC)
    add_definitions(-DFEATURE_ENABLE_HARDWARE_EXCEPTIONS)
endif(CLR_CMAKE_PLATFORM_UNIX)

# Set the RPATH of paltest_pal_sxs_test1 so that it can find dependencies without needing to set LD_LIBRARY
# For more information: http://www.cmake.org/Wiki/CMake_RPATH_handling.
if(CORECLR_SET_RPATH)
  if(CLR_CMAKE_PLATFORM_LINUX)
    set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
    set(CMAKE_INSTALL_RPATH "\$ORIGIN")
  endif(CLR_CMAKE_PLATFORM_LINUX)
endif(CORECLR_SET_RPATH)

# Test DLL1

set(DEF_SOURCES1 dlltest1.src)
convert_to_absolute_path(DEF_SOURCES1 ${DEF_SOURCES1})
set(EXPORTS_FILE1 ${CMAKE_CURRENT_BINARY_DIR}/dlltest1.exports)
generate_exports_file(${DEF_SOURCES1} ${EXPORTS_FILE1})

if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD)
    set(EXPORTS_LINKER_OPTION1 -Wl,--version-script=${EXPORTS_FILE1})
endif(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD)

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
    set(EXPORTS_LINKER_OPTION1 -Wl,-exported_symbols_list,${EXPORTS_FILE1})
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)

set(DLL1SOURCES dlltest1.cpp)
add_library(paltest_pal_sxs_test1_dll1 SHARED ${DLL1SOURCES})
add_custom_target(dlltest1_exports DEPENDS ${EXPORTS_FILE1})
set_property(TARGET paltest_pal_sxs_test1_dll1 APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION1})
set_property(TARGET paltest_pal_sxs_test1_dll1 APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE1})

add_dependencies(paltest_pal_sxs_test1_dll1
    dlltest1_exports
    coreclrpal
)

target_link_libraries(paltest_pal_sxs_test1_dll1
    ${COMMON_TEST_LIBRARIES}
    m
    coreclrpal
)

# Test DLL2

set(DEF_SOURCES2 dlltest2.src)
convert_to_absolute_path(DEF_SOURCES2 ${DEF_SOURCES2})
set(EXPORTS_FILE2 ${CMAKE_CURRENT_BINARY_DIR}/dlltest2.exports)
generate_exports_file(${DEF_SOURCES2} ${EXPORTS_FILE2})

if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD)
    set(EXPORTS_LINKER_OPTION2 -Wl,--version-script=${EXPORTS_FILE2})
endif(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD OR CMAKE_SYSTEM_NAME STREQUAL NetBSD)

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
    set(EXPORTS_LINKER_OPTION2 -Wl,-exported_symbols_list,${EXPORTS_FILE2})
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)

set(DLL2SOURCES dlltest2.cpp)
add_library(paltest_pal_sxs_test1_dll2 SHARED ${DLL2SOURCES})
add_custom_target(dlltest2_exports DEPENDS ${EXPORTS_FILE2})
set_property(TARGET paltest_pal_sxs_test1_dll2 APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION2})
set_property(TARGET paltest_pal_sxs_test1_dll2 APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE2})

add_dependencies(paltest_pal_sxs_test1_dll2
   dlltest2_exports
)

target_link_libraries(paltest_pal_sxs_test1_dll2
   ${COMMON_TEST_LIBRARIES}
)

# Main program

set(TESTSOURCES exceptionsxs.cpp)

add_executable(paltest_pal_sxs_test1 ${TESTSOURCES})

add_dependencies(paltest_pal_sxs_test1
   paltest_pal_sxs_test1_dll1
   paltest_pal_sxs_test1_dll2
)

target_link_libraries(paltest_pal_sxs_test1
   paltest_pal_sxs_test1_dll1
   paltest_pal_sxs_test1_dll2
)