summaryrefslogtreecommitdiffstats
path: root/test/plugin_lib/CMakeLists.txt
blob: 64356881bdb91658dea37cbbc3116b0d60d5e8e6 (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
cmake_minimum_required (VERSION 2.8.10)
PROJECT (HDF5_TEST_PLUGIN_LIB)

#-----------------------------------------------------------------------------
# Set the core name of the library
#-----------------------------------------------------------------------------
SET (HDF5_TEST_PLUGIN_LIB_CORENAME         "dynlib1")

#-----------------------------------------------------------------------------
# Set the true names of all the libraries if customized by external project
#-----------------------------------------------------------------------------
SET (HDF5_TEST_PLUGIN_LIB_NAME              "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_LIB_CORENAME}")

#-----------------------------------------------------------------------------
# Set the target names of all the libraries
#-----------------------------------------------------------------------------
SET (HDF5_TEST_PLUGIN_LIB_TARGET              ${HDF5_TEST_PLUGIN_LIB_CORENAME})

#-----------------------------------------------------------------------------
# Apply Definitions to compiler in this directory and below
#-----------------------------------------------------------------------------
ADD_DEFINITIONS (${HDF5_EXTRA_C_FLAGS})

#-----------------------------------------------------------------------------
# Setup include Directories
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (${HDF5_SRC_DIR})

#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------

SET (H5_TEST_PLUGIN_LIB_SRCS
    ${HDF5_TEST_PLUGIN_LIB_SOURCE_DIR}/dynlib1.c
)

#-----------------------------------------------------------------------------
# Generate the H5srcdir_str.h file containing user settings needed by compilation
#-----------------------------------------------------------------------------
SET (srcdir ${CMAKE_CURRENT_SOURCE_DIR})
CONFIGURE_FILE (${HDF5_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h  @ONLY)
INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR})

ADD_LIBRARY (${HDF5_TEST_PLUGIN_LIB_TARGET} ${LIB_TYPE} ${H5_TEST_PLUGIN_LIB_SRCS})
TARGET_LINK_LIBRARIES (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
#SET_GLOBAL_VARIABLE( HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_TEST_PLUGIN_LIB_TARGET}")
H5_SET_LIB_OPTIONS (
    ${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME}
    ${LIB_TYPE}
    HDF5_TEST_PLUGIN_LIB_NAME_RELEASE
    HDF5_TEST_PLUGIN_LIB_NAME_DEBUG
)
SET_TARGET_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN)

#
# Copy plugin library to a plugins folder
#

# make plugins dir
FILE (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
ADD_CUSTOM_COMMAND (
    TARGET     ${HDF5_TEST_PLUGIN_LIB_TARGET}
    POST_BUILD
    COMMAND    ${CMAKE_COMMAND}
    ARGS       -E copy_if_different 
     "$<TARGET_FILE:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
     "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_LIB_TARGET}>"
  )

##############################################################################
##############################################################################
###           T E S T S                                                    ###
##############################################################################
##############################################################################

#-- Adding test for plugin
ADD_EXECUTABLE (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c)
TARGET_NAMING (plugin ${LIB_TYPE})
TARGET_LINK_LIBRARIES (plugin ${HDF5_TEST_PLUGIN_LIB_TARGET})
SET_TARGET_PROPERTIES (plugin PROPERTIES FOLDER test)

ADD_TEST (NAME H5PLUGIN-plugin COMMAND $<TARGET_FILE:plugin>)
SET_TESTS_PROPERTIES (H5PLUGIN-plugin PROPERTIES ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/plugins/