Skip to content

Commit

Permalink
Finally made cmake work statically on both windows and linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
Noscka committed Aug 30, 2023
1 parent 84407cb commit 4d7d3d7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ set(CMAKE_CXX_STANDARD 20)

project ("Project LVATT")

if(WIN32)
add_compile_options (/MT)
endif(WIN32)

message(STATUS "CMAKE_CXX_STANDARD = ${CMAKE_CXX_STANDARD}")
message(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}")
message(STATUS "CMAKE_C_FLAGS_RELEASE = ${CMAKE_C_FLAGS_RELEASE}")

#set(BUILD_SHARED_LIBS OFF)
option(BUILD_SHARED_LIBS "Link Statically" OFF)

# Include sub-projects.
add_subdirectory ("External")
add_subdirectory ("LVATT")
add_subdirectory (External)
add_subdirectory (LVATT)
2 changes: 0 additions & 2 deletions External/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC))
endif()
endif()

set(BUILD_SHARED_LIBS OFF)

add_subdirectory(DSPFilters)
add_subdirectory(Whisper)
10 changes: 2 additions & 8 deletions External/DSPFilters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ endif()

aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/source SOURCE_LIB)

add_library(${PROJECT_NAME} STATIC ${SOURCE_LIB})
add_library(${PROJECT_NAME} ${SOURCE_LIB})

target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)

# make library static
if(WIN32)
target_compile_options(${PROJECT_NAME} PUBLIC /MT)
target_link_options(${PROJECT_NAME} PUBLIC /INCREMENTAL:NO /NODEFAULTLIB:MSVCRT)
endif(WIN32)
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
6 changes: 2 additions & 4 deletions LVATT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ add_executable (${PROJECT_NAME} "LVATT.cpp" "Headers/AudioTranscribing.hpp" "Hea
target_link_libraries(${PROJECT_NAME} -static DSPFilters)
target_link_libraries(${PROJECT_NAME} -static whisper)

set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# make executable static
if(WIN32)
target_compile_options(${PROJECT_NAME} PUBLIC /MT)
target_link_options(${PROJECT_NAME} PUBLIC /INCREMENTAL:NO /NODEFAULTLIB:MSVCRT)
endif(WIN32)

#install(TARGETS ${PROJECT_NAME} DESTINATION bin)

0 comments on commit 4d7d3d7

Please sign in to comment.