Skip to content

Commit 61fa3d2

Browse files
committed
fix output dir according to configuration;add version and linkflag support
1 parent 3d4f8d6 commit 61fa3d2

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

templates/cmake.mpd

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,43 +41,25 @@ endif()
4141
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%>)
4242
<%marker(macros)%>
4343

44-
<%if(exeout)%>
45-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_exeout%>)
46-
<%if(use_lib_modifier)%>
47-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG <%env_exeout%>)
48-
<%endif%>
49-
<%endif%>
50-
<%if(!exename)%>
51-
<%if(libout)%>
52-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY <%env_libout%>)
53-
<%if(use_lib_modifier)%>
44+
<%if(exename)%>
5445
<%foreach(configurations)%>
55-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
46+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_<%uc(configuration)%> <%exeout%>)
47+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_<%uc(configuration)%> <%libout%>)
5648
<%endfor%>
5749
<%endif%>
58-
<%endif%>
59-
<%if(dllout)%>
60-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY <%env_dllout%>)
61-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_dllout%>)
62-
<%if(use_lib_modifier)%>
50+
51+
<%if(staticname)%>
6352
<%foreach(configurations)%>
64-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_dllout%>)
65-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_dllout%>)
53+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_<%uc(configuration)%> <%libout%>)
6654
<%endfor%>
6755
<%endif%>
68-
<%else%>
69-
<%if(libout)%>
70-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY <%env_libout%>)
71-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_libout%>)
72-
<%if(use_lib_modifier)%>
56+
57+
<%if(sharedname)%>
7358
<%foreach(configurations)%>
74-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
75-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_<%uc(configuration)%> <%env_libout%>)
59+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_<%uc(configuration)%> <%libout%>)
60+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_<%uc(configuration)%> <%dllout%>)
7661
<%endfor%>
7762
<%endif%>
78-
<%endif%>
79-
<%endif%>
80-
<%endif%>
8163

8264
<%if(compile_flags)%>
8365
target_compile_options(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PUBLIC <%compile_flags%>)
@@ -93,9 +75,18 @@ if(NOT BUILD_SHARED_LIBS)
9375
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
9476
endif()
9577
<%endif%>
78+
<%if(linkflags)%>
79+
set_target_properties(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PROPERTIES LINK_FLAGS <%linkflags%>)
80+
<%endif%>
9681
<%else%>
9782
<%if(sharedname)%>
9883
add_library(${PROJECT_TARGET_<%uc(normalize(project_name))%>} SHARED ${SOURCE_FILES_<%uc(normalize(project_name))%>})
84+
<%if(version)%>
85+
set_target_properties(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PROPERTIES VERSION <%version%>)
86+
<%endif%>
87+
<%if(linkflags)%>
88+
set_target_properties(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PROPERTIES LINK_FLAGS <%linkflags%>)
89+
<%endif%>
9990
<%if(dynamicflags)%>
10091
if(BUILD_SHARED_LIBS)
10192
target_compile_definitions(${PROJECT_TARGET_<%uc(normalize(project_name))%>} PRIVATE <%dynamicflags%>)

0 commit comments

Comments
 (0)