annotate cmake/MalikaniaFunctions.cmake @ 47:7097a91b08a8

Tools: add mlk-bcc tool, closes #596
author David Demelier <markand@malikania.fr>
date Wed, 07 Dec 2016 20:51:19 +0100
parents f30c84b4b9ed
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
1 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
2 # CMakeLists.txt -- CMake build system for malikania
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
3 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
4 # Copyright (c) 2013-2016 Malikania Authors
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
5 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
6 # Permission to use, copy, modify, and/or distribute this software for any
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
7 # purpose with or without fee is hereby granted, provided that the above
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
8 # copyright notice and this permission notice appear in all copies.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
9 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
17 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
18
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
19 include(CMakeParseArguments)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
20
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
21 # ---------------------------------------------------------
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
22 # The following macros are available:
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
23 #
47
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
24 # malikania_build_assets
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
25 # ----------------------
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
26 #
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
27 # malikania_build_assets(inputs outputs)
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
28 #
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
29 # Create binary data as C++ arrays for inclusion in source code. Static assets
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
30 # increases the executable size so use this when really needed.
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
31 #
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
32 # The macro iterates over the input data which can be any files and generates
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
33 # outputs file in the form CMAKE_CURRENT_BINARY_DIR/assets/basename.cpp.
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
34 #
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
35 # The macro removes the extension from the filename and create a static array
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
36 # with that name, thus you need to specify a filename that is compatible with
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
37 # C++ identifiers!
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
38 #
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
39 # Correct:
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
40 # - myfile.png
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
41 # - startup_logo.png
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
42 #
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
43 # Incorrect:
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
44 # - useful-code.ogg
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
45 # - archive.tar.xz
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
46 #
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
47 # malikania_define_executable
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
48 # ---------------------------
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
49 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
50 # malikania_define_executable(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
51 # TARGET The target name
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
52 # SOURCES The list of sources
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
53 # FLAGS (Optional) List of flags
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
54 # INCLUDES (Optional) List of include directories
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
55 # LIBRARIES (Optional) List of libraries
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
56 # )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
57 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
58 # Create an executable. Be sure to quote SOURCES, if not only the first file will be passed.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
59 # If you need flags, just pass them without -D or /D, this is automatically done for you.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
60 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
61 # malikania_create_library
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
62 # ------------------------
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
63 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
64 # malikania_create_library(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
65 # TARGET The target name
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
66 # SOURCES The sources
47
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
67 # ASSETS (Optional) Additional assets files
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
68 # FLAGS (Optional) List of flags
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
69 # PRIVATE_INCLUDES (Optional) List of includes only for building the library
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
70 # PUBLIC_INCLUDES (Optional) List of public includes to share with the library users
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
71 # LIBRARIES (Optional) List of libraries to link against
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
72 # )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
73 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
74 # Create a shared library. Follow the same specification as malikania_define_executable.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
75 # However, additional PRIVATE_INCLUDES and PUBLIC_INCLUDES are available.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
76 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
77 # malikania_create_test
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
78 # ---------------------
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
79 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
80 # malikania_create_test(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
81 # NAME Test name (must be lowercase)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
82 # SOURCES Test sources files
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
83 # LIBRARIES (Optional) Libraries to link to
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
84 # RESOURCES (Optional) Resources files to copy verbatim
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
85 # )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
86 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
87 # This will generate a target named test-<name> where name is the parameter NAME. The test is created
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
88 # under CMAKE_BINARY_DIR/test/<NAME> and resources are copied there with the same hierarchy.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
89 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
90 # setg
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
91 # ----
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
92 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
93 # setg(var value)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
94 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
95 # Set a cache variable internal with name var.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
96 #
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
97 # ---------------------------------------------------------
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
98
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
99 function(apply_flags target flags)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
100 # Add MALIKANIA_BUILD to enable declspec(dllexport) on Windows
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
101 if (${flags})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
102 target_compile_definitions(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
103 ${target}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
104 PRIVATE ${flags}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
105 PRIVATE "MALIKANIA_BUILD"
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
106 )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
107 endif ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
108 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
109
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
110 function(apply_public_includes target var)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
111 if (${var})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
112 target_include_directories(${target} PUBLIC ${${var}})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
113 endif ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
114
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
115 target_include_directories(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
116 ${target}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
117 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/malikania/${WITH_BACKEND_DIRECTORY}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
118 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
119 )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
120 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
121
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
122 function(apply_private_includes target var)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
123 if (${var})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
124 target_include_directories(${target} PRIVATE ${${var}})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
125 endif ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
126 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
127
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
128 function(apply_includes target var)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
129 if (${var})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
130 target_include_directories(${target} PRIVATE ${${var}})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
131 endif ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
132 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
133
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
134 function(apply_libraries target libs)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
135 if (${libs})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
136 target_link_libraries(${target} ${${libs}})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
137 endif ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
138 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
139
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
140 function(check_args prefix list)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
141 foreach (e ${list})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
142 if (NOT ${prefix}_${e})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
143 message(FATAL_ERROR "Please set `${e}' parameter")
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
144 endif ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
145 endforeach ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
146 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
147
47
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
148 macro(malikania_build_assets inputs outputs)
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
149 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/assets)
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
150
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
151 foreach (in ${inputs})
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
152 get_filename_component(basename ${in} NAME_WE)
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
153 set(out ${CMAKE_CURRENT_BINARY_DIR}/assets/${basename}.cpp)
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
154 add_custom_command(
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
155 OUTPUT ${out}
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
156 COMMENT "Generating binary data from ${in}"
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
157 DEPENDS ${in}
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
158 COMMAND
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
159 $<TARGET_FILE:mlk-bcc> ${basename} ${in} ${out}
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
160 )
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
161 list(APPEND ${outputs} ${out})
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
162 endforeach ()
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
163 endmacro()
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
164
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
165 function(malikania_define_executable)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
166 set(singleArgs TARGET)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
167 set(multiArgs SOURCES FLAGS INCLUDES LIBRARIES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
168 set(mandatory TARGET SOURCES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
169
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
170 cmake_parse_arguments(EXE "" "${singleArgs}" "${multiArgs}" ${ARGN})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
171 check_args(EXE ${mandatory})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
172
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
173 add_executable(${EXE_TARGET} ${EXE_SOURCES})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
174
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
175 apply_libraries(${EXE_TARGET} EXE_LIBRARIES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
176 apply_includes(${EXE_TARGET} EXE_INCLUDES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
177 apply_flags(${EXE_TARGET} EXE_FLAGS)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
178 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
179
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
180 function(malikania_create_library)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
181 set(singleArgs TARGET)
47
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
182 set(multiArgs ASSETS SOURCES FLAGS PRIVATE_INCLUDES PUBLIC_INCLUDES LIBRARIES)
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
183 set(mandatory TARGET SOURCES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
184
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
185 cmake_parse_arguments(LIB "" "${singleArgs}" "${multiArgs}" ${ARGN})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
186 check_args(LIB ${mandatory})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
187
47
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
188 # Enable assets for libraries.
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
189 malikania_build_assets("${LIB_ASSETS}" assets)
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
190
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
191 add_library(${LIB_TARGET} SHARED ${LIB_SOURCES} ${assets})
7097a91b08a8 Tools: add mlk-bcc tool, closes #596
David Demelier <markand@malikania.fr>
parents: 44
diff changeset
192 target_include_directories(${LIB_TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/assets)
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
193
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
194 # Remove lib suffix to avoid conflict with client and libclient targets
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
195 set_target_properties(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
196 ${LIB_TARGET}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
197 PROPERTIES
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
198 PREFIX ""
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
199 )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
200
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
201 list(APPEND LIB_LIBRARIES duktape)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
202
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
203 apply_libraries(${LIB_TARGET} LIB_LIBRARIES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
204 apply_private_includes(${LIB_TARGET} LIB_PRIVATE_INCLUDES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
205 apply_public_includes(${LIB_TARGET} LIB_PUBLIC_INCLUDES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
206 apply_flags(${LIB_TARGET} LIB_FLAGS)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
207 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
208
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
209 function(malikania_create_test)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
210 set(singleArgs NAME)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
211 set(multiArgs LIBRARIES SOURCES RESOURCES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
212
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
213 set(mandatory NAME SOURCES)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
214
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
215 cmake_parse_arguments(TEST "" "${singleArgs}" "${multiArgs}" ${ARGN})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
216 check_args(TEST ${mandatory})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
217
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
218 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/test/${TEST_NAME})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
219
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
220 if (UNIX)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
221 list(APPEND TEST_LIBRARIES pthread)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
222 endif ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
223
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
224 # Resources files added before as custom output
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
225 foreach (f ${TEST_RESOURCES})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
226 get_filename_component(absolute ${f} ABSOLUTE)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
227 file(RELATIVE_PATH basename ${CMAKE_CURRENT_SOURCE_DIR} ${absolute})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
228 set(output ${CMAKE_BINARY_DIR}/test/${TEST_NAME}/${basename})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
229
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
230 add_custom_command(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
231 OUTPUT ${output}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
232 COMMAND ${CMAKE_COMMAND} -E copy ${absolute} ${output}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
233 DEPENDS ${absolute}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
234 )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
235
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
236 list(APPEND TEST_SOURCES ${absolute})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
237 list(APPEND outputs ${output})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
238 endforeach ()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
239
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
240 add_executable(test-${TEST_NAME} ${TEST_SOURCES} ${outputs})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
241 source_group(private\\Resources FILES ${outputs})
44
f30c84b4b9ed Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
242 target_compile_definitions(
f30c84b4b9ed Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
243 test-${TEST_NAME}
f30c84b4b9ed Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
244 PRIVATE
f30c84b4b9ed Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
245 BOOST_TEST_DYN_LINK
f30c84b4b9ed Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
246 SOURCE_DIRECTORY=\"${CMAKE_BINARY_DIR}/test/${TEST_NAME}\"
f30c84b4b9ed Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
247 )
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
248 set_target_properties(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
249 test-${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
250 PROPERTIES
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
251 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test/${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
252 RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/test/${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
253 RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/test/${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
254 RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/test/${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
255 RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/test/${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
256 )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
257 add_test(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
258 NAME ${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
259 COMMAND $<TARGET_FILE:test-${TEST_NAME}>
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
260 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test/${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
261 )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
262
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
263 target_link_libraries(
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
264 test-${TEST_NAME}
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
265 ${TEST_LIBRARIES}
44
f30c84b4b9ed Tests: switch from GoogleTest to Boost.Unit, closes #588
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
266 ${Boost_unit_test_framework_LIBRARY}
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
267 )
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
268
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
269 add_dependencies(tests test-${TEST_NAME})
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
270 endfunction()
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
271
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
272 macro(setg var value)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
273 set(${var} ${value} CACHE INTERNAL "" FORCE)
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
274 endmacro()