Skip to content

Commit

Permalink
Build client with /MT
Browse files Browse the repository at this point in the history
  • Loading branch information
7Hazard committed Aug 11, 2020
1 parent c76e0f7 commit 6d632d0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ project(altv-capi)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
Expand Down Expand Up @@ -53,6 +51,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/altv-capi-client/lib
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/altv-capi-client/bin
)
target_compile_options(altv-capi-client PRIVATE
$<IF:$<CONFIG:Debug>,/MTd,/MT>
)
add_custom_command(TARGET altv-capi-client POST_BUILD # POST BUILD COMMANDS
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/client/altv-capi.h ${PROJECT_BINARY_DIR}/altv-capi-client/include/client/altv-capi.h
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/altv-capi-client.h ${PROJECT_BINARY_DIR}/altv-capi-client/include/altv-capi-client.h
Expand All @@ -76,6 +77,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/altv-capi-client-static/bin
POSITION_INDEPENDENT_CODE ON
)
target_compile_options(altv-capi-client-static PRIVATE
$<IF:$<CONFIG:Debug>,/MTd,/MT>
)
add_custom_command(TARGET altv-capi-client-static POST_BUILD # POST BUILD COMMANDS
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/client/altv-capi.h ${PROJECT_BINARY_DIR}/altv-capi-client-static/include/client/altv-capi.h
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/altv-capi-client.h ${PROJECT_BINARY_DIR}/altv-capi-client-static/include/altv-capi-client.h
Expand All @@ -102,6 +106,7 @@ else()
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()

add_library(altv-capi-server SHARED
${CMAKE_SOURCE_DIR}/altv-capi-server.cpp
)
Expand All @@ -117,6 +122,12 @@ set_target_properties(altv-capi-server PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/altv-capi-server/lib
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/altv-capi-server/bin
)
target_compile_options(altv-capi-server PRIVATE
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:>>:/MD>
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:Debug>>:/MDd>
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:Release>>:/MD>
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:RelWithDebInfo>>:/MD>
)
add_custom_command(TARGET altv-capi-server POST_BUILD # POST BUILD COMMANDS
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/server/altv-capi.h ${PROJECT_BINARY_DIR}/altv-capi-server/include/server/altv-capi.h
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/altv-capi-server.h ${PROJECT_BINARY_DIR}/altv-capi-server/include/altv-capi-server.h
Expand All @@ -140,6 +151,12 @@ set_target_properties(altv-capi-server-static PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/altv-capi-server-static/bin
POSITION_INDEPENDENT_CODE ON
)
target_compile_options(altv-capi-server-static PRIVATE
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:>>:/MD>
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:Debug>>:/MDd>
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:Release>>:/MD>
$<$<AND:$<PLATFORM_ID:Windows>,$<CONFIG:RelWithDebInfo>>:/MD>
)
add_custom_command(TARGET altv-capi-server POST_BUILD # POST BUILD COMMANDS
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/server/altv-capi.h ${PROJECT_BINARY_DIR}/altv-capi-server-static/include/server/altv-capi.h
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/altv-capi-server.h ${PROJECT_BINARY_DIR}/altv-capi-server-static/include/altv-capi-server.h
Expand Down

0 comments on commit 6d632d0

Please sign in to comment.