"platforms/vscode:/vscode.git/clone" did not exist on "a5a52dd112032c7cd50d3461565d03f5b5a54384"
CMakeLists.txt 2.72 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Generate and install examples.
#
# This is boilerplate code for generating a set of executables, one per
# .cpp file in an "examples" subdirectory. 
#
# For IDEs that can deal with PROJECT_LABEL properties (at least
# Visual Studio) the projects for building each of these adhoc
# executables will be labeled "Example - TheExampleName" if a file
# TheExampleName.cpp is found in this directory.
#
# We check the BUILD_TESTING_{SHARED,STATIC} variables to determine
# whether to build dynamically linked, statically linked, or both
# versions of the executable.

Michael Sherman's avatar
Michael Sherman committed
15
16
17
18
19

SET(OpenMM_CWRAPPER_LIB "OpenMM_CWrapper")

ADD_SUBDIRECTORY(wrappers)

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
SET(BUILD_TESTING_SHARED 1)
SET(BUILD_TESTING_STATIC 1)

FILE(GLOB EXAMPLES "*.cpp")
FOREACH(EX_PROG ${EXAMPLES})
    GET_FILENAME_COMPONENT(EX_SRC  ${EX_PROG} NAME)
    GET_FILENAME_COMPONENT(EX_ROOT ${EX_PROG} NAME_WE)

    IF (BUILD_TESTING_SHARED)
        # Link with shared library
        ADD_EXECUTABLE(${EX_ROOT} ${EX_PROG})
        SET_TARGET_PROPERTIES(${EX_ROOT}
		PROPERTIES
	      PROJECT_LABEL "Example - ${EX_ROOT}")
        TARGET_LINK_LIBRARIES(${EX_ROOT} ${SHARED_TARGET})
    ENDIF (BUILD_TESTING_SHARED)

    IF (BUILD_TESTING_STATIC)
        # Link with static library
        SET(EX_STATIC ${EX_ROOT}Static)
        ADD_EXECUTABLE(${EX_STATIC} ${EX_PROG})
        SET_TARGET_PROPERTIES(${EX_STATIC}
		PROPERTIES
		COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES"
		PROJECT_LABEL "Example - ${EX_STATIC}")
        TARGET_LINK_LIBRARIES(${EX_STATIC} ${STATIC_TARGET})
    ENDIF (BUILD_TESTING_STATIC)

    INSTALL(FILES ${EX_SRC} DESTINATION examples)

ENDFOREACH(EX_PROG ${ADHOC_TESTS})

Michael Sherman's avatar
Michael Sherman committed
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
FILE(GLOB EXAMPLES "*.c")
FOREACH(EX_PROG ${EXAMPLES})
    GET_FILENAME_COMPONENT(EX_SRC  ${EX_PROG} NAME)
    GET_FILENAME_COMPONENT(EX_ROOT ${EX_PROG} NAME_WE)

    IF (BUILD_TESTING_SHARED)
        # Link with shared library
        ADD_EXECUTABLE(${EX_ROOT} ${EX_PROG})
        SET_TARGET_PROPERTIES(${EX_ROOT}
		PROPERTIES
	      PROJECT_LABEL "Example C - ${EX_ROOT}")
        TARGET_LINK_LIBRARIES(${EX_ROOT} 
            ${OpenMM_CWRAPPER_LIB} ${SHARED_TARGET})
    ENDIF (BUILD_TESTING_SHARED)

    IF (BUILD_TESTING_STATIC)
        # Link with static library
        SET(EX_STATIC ${EX_ROOT}Static)
        ADD_EXECUTABLE(${EX_STATIC} ${EX_PROG})
        SET_TARGET_PROPERTIES(${EX_STATIC}
		PROPERTIES
		COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES"
		PROJECT_LABEL "Example C - ${EX_STATIC}")
        TARGET_LINK_LIBRARIES(${EX_STATIC} 
		${OpenMM_CWRAPPER_LIB} ${STATIC_TARGET})
    ENDIF (BUILD_TESTING_STATIC)

    INSTALL(FILES ${EX_SRC} DESTINATION examples)

ENDFOREACH(EX_PROG ${ADHOC_TESTS})

83
INSTALL(FILES README.txt DESTINATION examples)