summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorChad Elliott <elliottc@objectcomputing.com>2022-10-25 10:58:49 -0500
committerChad Elliott <elliottc@objectcomputing.com>2022-10-25 10:58:49 -0500
commit75f1165efc6dda4c9f76013a7fbf918b4b2a28c5 (patch)
tree84f6eef04339b13611c8d0e53d47e81163253f5c /templates
parent3812eb06faaaf511fd53620826b0482aed6d4c3e (diff)
downloadMPC-75f1165efc6dda4c9f76013a7fbf918b4b2a28c5.tar.gz
Initial modifications to support switching between shared and static libraries.
Diffstat (limited to 'templates')
-rw-r--r--templates/cmake.mpd28
1 files changed, 24 insertions, 4 deletions
diff --git a/templates/cmake.mpd b/templates/cmake.mpd
index e4d2c290..8c305482 100644
--- a/templates/cmake.mpd
+++ b/templates/cmake.mpd
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION <%cmake_minimum_required(3.12.0)%>)
<%marker(top)%>
project(<%project_name%> <%language%>)
+option(BUILD_SHARED_LIBS "Build using shared libraries" <%if(need_staticflags)%>OFF<%else%>ON<%endif%>)
<%if(pre_find_package)%>
<%pre_find_package%>
@@ -23,7 +24,7 @@ find_package(ACE REQUIRED)
<%endif%>
set(SOURCE_FILES <%source_files%>)
<%if(libs || lit_libs || pure_libs)%>
-set(TARGET_LINK_LIBRARIES<%if(libs)%> <%foreach(configurations)%><%fornotfirst(" ")%>$<$<CONFIG:<%configuration%>>:<%foreach(libs)%><%fornotfirst(" ")%><%lib%><%lib_modifier%><%endfor%>><%fornotlast("\n")%><%endfor%><%endif%><%if(lit_libs)%> <%lit_libs%><%endif%><%if(pure_libs)%> <%pure_libs%><%endif%>)
+set(TARGET_LINK_LIBRARIES<%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%>)
<%endif%>
set(PROJECT_TARGET <%if(exename)%><%exename%><%else%><%if(sharedname)%><%sharedname%><%else%><%if(staticname)%><%staticname%><%else%><%project_name%><%endif%><%endif%><%endif%>)
<%marker(macros)%>
@@ -72,11 +73,30 @@ add_compile_options(<%compile_flags%>)
<%if(exename)%>
add_executable(${PROJECT_TARGET} ${SOURCE_FILES})
target_link_libraries(${PROJECT_TARGET} ${TARGET_LINK_LIBRARIES})
+<%if(staticflags)%>
+if(NOT BUILD_SHARED_LIBS)
+ add_compile_definitions(<%staticflags%>)
+ set_property(TARGET ${PROJECT_TARGET} PROPERTY
+ MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+endif()
+<%endif%>
<%else%>
<%if(sharedname)%>
-add_library(${PROJECT_TARGET} SHARED ${SOURCE_FILES})
+add_library(${PROJECT_TARGET} ${SOURCE_FILES})
<%if(dynamicflags)%>
-add_compile_definitions(<%dynamicflags%>)
+if(BUILD_SHARED_LIBS)
+ add_compile_definitions(<%dynamicflags%>)
+<%if(staticflags)%>
+else()
+ add_compile_definitions(<%staticflags%>)
+<%endif%>
+endif()
+<%else%>
+<%if(staticflags)%>
+if(NOT BUILD_SHARED_LIBS)
+ add_compile_definitions(<%staticflags%>)
+endif()
+<%endif%>
<%endif%>
target_link_libraries(${PROJECT_TARGET} ${TARGET_LINK_LIBRARIES})
<%else%>
@@ -90,7 +110,7 @@ add_compile_definitions(<%staticflags%>)
<%if(use_lib_modifier)%>
<%foreach(configurations)%>
<%if(lib_modifier)%>
-set_target_properties(${PROJECT_TARGET} PROPERTIES <%uc(configuration)%>_POSTFIX "<%lib_modifier%>")
+set_target_properties(${PROJECT_TARGET} PROPERTIES <%uc(configuration)%>_POSTFIX "${LIBRARY_DECORATOR}<%lib_modifier%>")
<%endif%>
<%endfor%>
<%endif%>