summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorChad Elliott <elliottc@objectcomputing.com>2022-11-15 07:28:29 -0600
committerChad Elliott <elliottc@objectcomputing.com>2022-11-15 07:28:29 -0600
commit1d04f7001338262563dd1e527015366a6bf2fa23 (patch)
tree0df1927f8bd2e721027ff879397efd2955862854 /templates
parentfe2179434123896ad860c6ae3f092c7ab86f4c84 (diff)
downloadMPC-1d04f7001338262563dd1e527015366a6bf2fa23.tar.gz
Added a template function to help determine if a variable value is a CMake macro usage. This allows us to handle those values in a special way in the template to allow conditionally linking in libraries.
Diffstat (limited to 'templates')
-rw-r--r--templates/cmake.mpd11
1 files changed, 9 insertions, 2 deletions
diff --git a/templates/cmake.mpd b/templates/cmake.mpd
index f3e20dd9..9d929dd4 100644
--- a/templates/cmake.mpd
+++ b/templates/cmake.mpd
@@ -13,10 +13,17 @@ find_package(<%package%> REQUIRED)
set(SOURCE_FILES_<%uc(normalize(project_name))%> <%source_files%>)
<%if(libs || lit_libs || pure_libs)%>
+<%foreach(libs)%>
+<%if(cmake_macro(lib))%>
+if(<%cmake_macro(lib)%>)
+ set(<%cmake_macro(lib)%>_DEFINED TRUE)
+endif()
+<%endif%>
+<%endfor%>
if(CMAKE_CONFIGURATION_TYPES)
-set(TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%><%if(libs)%> <%foreach(configurations)%><%fornotfirst(" ")%>$<$<CONFIG:<%configuration%>>:<%foreach(libs)%><%fornotfirst(" ")%><%lib%>${LIBRARY_DECORATOR}<%lib_modifier%><%endfor%>><%fornotlast("\n")%><%endfor%><%endif%><%if(lit_libs)%> <%lit_libs%><%endif%><%if(pure_libs)%> <%pure_libs%><%endif%>)
+set(TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%><%if(libs)%> <%foreach(configurations)%><%fornotfirst(" ")%>$<$<CONFIG:<%configuration%>>:<%foreach(libs)%><%fornotfirst(" ")%><%if(cmake_macro(lib))%>$<IF:$<BOOL:${<%cmake_macro(lib)%>_DEFINED}>,<%lib%>${LIBRARY_DECORATOR}<%lib_modifier%>,><%else%><%lib%>${LIBRARY_DECORATOR}<%lib_modifier%><%endif%><%endfor%>><%fornotlast("\n")%><%endfor%><%endif%><%if(lit_libs)%> <%lit_libs%><%endif%><%if(pure_libs)%> <%pure_libs%><%endif%>)
else()
-set(TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%><%if(libs)%><%foreach(libs)%> <%lib%>${LIBRARY_DECORATOR}<%endfor%><%endif%><%if(lit_libs)%> <%lit_libs%><%endif%><%if(pure_libs)%> <%pure_libs%><%endif%>)
+set(TARGET_LINK_LIBRARIES_<%uc(normalize(project_name))%><%if(libs)%><%foreach(libs)%> <%if(cmake_macro(lib))%>$<IF:$<BOOL:${<%cmake_macro(lib)%>_DEFINED}>,<%lib%>${LIBRARY_DECORATOR},><%else%><%lib%>${LIBRARY_DECORATOR}<%endif%><%endfor%><%endif%><%if(lit_libs)%> <%lit_libs%><%endif%><%if(pure_libs)%> <%pure_libs%><%endif%>)
endif()
<%endif%>
set(PROJECT_TARGET_<%uc(normalize(project_name))%> <%if(exename)%><%exename%><%else%><%if(sharedname)%><%sharedname%>${LIBRARY_DECORATOR}<%else%><%if(staticname)%><%staticname%>${LIBRARY_DECORATOR}<%else%><%project_name%>${LIBRARY_DECORATOR}<%endif%><%endif%><%endif%>)