Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some build modifications #46

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@ jobs:
-DBMX_TEST_WITH_VALGRIND=ON
-DLIBMXF_TEST_WITH_VALGRIND=ON
-DLIBMXFPP_TEST_WITH_VALGRIND=ON
- name: macos
- name: macos-brew
os: macos-latest
cmake_config_args: >-
-DCMAKE_BUILD_TYPE=Debug
-DBMX_BUILD_WITH_LIBCURL=ON
- name: macos-xcode-universal
os: macos-latest
cmake_config_args: >-
-G Xcode
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
-DBUILD_SHARED_LIBS=OFF
-DBMX_BUILD_URIPARSER_SOURCE=ON
-DBMX_BUILD_WITH_LIBCURL=ON
cmake_build_args: >-
--config Debug
cmake_test_args: >-
-C Debug
- name: windows
os: windows-latest
cmake_build_args: >-
Expand All @@ -38,7 +50,7 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Install dependencies (Ubuntu)
- name: Install dependencies (ubuntu)
if: ${{ contains(matrix.os, 'ubuntu') }}
shell: bash
run: |
Expand All @@ -54,12 +66,19 @@ jobs:
liburiparser-dev \
libexpat1-dev \
libcurl4-openssl-dev
- name: Install dependencies (MacOS)
if: ${{ contains(matrix.os, 'macos') }}

- name: Install dependencies (macos-brew)
if: ${{ matrix.name == 'macos-brew' }}
shell: bash
run: |
brew install git cmake expat uriparser curl

- name: Install dependencies (macos-xcode-universal)
if: ${{ matrix.name == 'macos-xcode-universal' }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Show Versions
shell: bash
run: |
Expand Down
37 changes: 27 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
# Set policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)
# Set the policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY,
# unless it has already been set
if(POLICY CMP0091)
cmake_policy(GET CMP0091 CMP0091_value)
if(NOT CMP0091_value)
cmake_policy(SET CMP0091 NEW)
cmake_policy(GET CMP0091 CMP0091_value)
endif()
else()
set(CMP0091_value OLD)
endif()

project(bmx
Expand All @@ -14,15 +21,19 @@ project(bmx

include("${CMAKE_CURRENT_LIST_DIR}/cmake/options.cmake")

if(MSVC AND BMX_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
# cmake version >= 3.15: Use MultiThreadedDLL runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
if(MSVC AND CMP0091_value STREQUAL NEW)
if(BMX_SET_MSVC_RUNTIME STREQUAL "MD")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
elseif(BMX_SET_MSVC_RUNTIME STREQUAL "MT")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()

if(BUILD_SHARED_LIBS)
if(BUILD_SHARED_LIBS OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

set(CMAKE_CXX_STANDARD 11)

# Set the test samples output directory
Expand All @@ -44,10 +55,16 @@ if(MSVC)
add_compile_options(/W3 /EHsc)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

if(BMX_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_LESS 3.15.0)
# cmake version < 3.15: Update compiler flags to use the MultiThreadedDLL runtime
if(CMP0091_value STREQUAL OLD AND NOT BMX_SET_MSVC_RUNTIME STREQUAL "default")
# Update compiler flags to use a particular runtime
macro(update_msvc_runtime_flags flags)
string(REGEX REPLACE "/MT" "/MD" ${flags} "${${flags}}")
if(BMX_SET_MSVC_RUNTIME STREQUAL "MD")
# Use MultiThreadedDLL runtime
string(REGEX REPLACE "/MT" "/MD" ${flags} "${${flags}}")
elseif(BMX_SET_MSVC_RUNTIME STREQUAL "MT")
# Use MultiThreaded runtime
string(REGEX REPLACE "/MD" "/MT" ${flags} "${${flags}}")
endif()
endmacro()

update_msvc_runtime_flags(CMAKE_C_FLAGS)
Expand Down
5 changes: 3 additions & 2 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ elseif(MSVC)
# Shared library currently not supported
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build using shared libraries")

# Option to set to use the MultiThreadedDLL runtime
option(BMX_SET_MSVC_RUNTIME "Enable setting MSVC runtime to MultiThreadedDLL" ON)
# Option to set to use the runtime
set(BMX_SET_MSVC_RUNTIME "MD" CACHE STRING "Set MSVC debug/release runtime to 'MD' (MultiThreadedDLL), 'MT' (MultiThreaded) or 'default' (use the default)")
set_property(CACHE BMX_SET_MSVC_RUNTIME PROPERTY STRINGS MD MT default)
endif()
37 changes: 27 additions & 10 deletions deps/libMXF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
# Set policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)
# Set the policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY,
# unless it has already been set
if(POLICY CMP0091)
cmake_policy(GET CMP0091 CMP0091_value)
if(NOT CMP0091_value)
cmake_policy(SET CMP0091 NEW)
cmake_policy(GET CMP0091 CMP0091_value)
endif()
else()
set(CMP0091_value OLD)
endif()

project(libMXF
Expand All @@ -14,15 +21,19 @@ project(libMXF

include("${CMAKE_CURRENT_LIST_DIR}/cmake/options.cmake")

if(MSVC AND LIBMXF_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
# cmake version >= 3.15: Use MultiThreadedDLL runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
if(MSVC AND CMP0091_value STREQUAL NEW)
if(LIBMXF_SET_MSVC_RUNTIME STREQUAL "MD")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
elseif(LIBMXF_SET_MSVC_RUNTIME STREQUAL "MT")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()

if(BUILD_SHARED_LIBS)
if(BUILD_SHARED_LIBS OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

set(CMAKE_CXX_STANDARD 11)

# Set the test samples output directory
Expand All @@ -44,10 +55,16 @@ if(MSVC)
add_compile_options(/W3)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

if(LIBMXF_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_LESS 3.15.0)
# cmake version < 3.15: Update compiler flags to use the MultiThreadedDLL runtime
if(CMP0091_value STREQUAL OLD AND NOT LIBMXF_SET_MSVC_RUNTIME STREQUAL default)
# Update compiler flags to use a particular runtime
macro(update_msvc_runtime_flags flags)
string(REGEX REPLACE "/MT" "/MD" ${flags} "${${flags}}")
if(LIBMXF_SET_MSVC_RUNTIME STREQUAL "MD")
# Use MultiThreadedDLL runtime
string(REGEX REPLACE "/MT" "/MD" ${flags} "${${flags}}")
elseif(LIBMXF_SET_MSVC_RUNTIME STREQUAL "MT")
# Use MultiThreaded runtime
string(REGEX REPLACE "/MD" "/MT" ${flags} "${${flags}}")
endif()
endmacro()

update_msvc_runtime_flags(CMAKE_C_FLAGS)
Expand Down
5 changes: 3 additions & 2 deletions deps/libMXF/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ elseif(MSVC)
# Shared library currently not supported
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build using shared libraries")

# Option to set to use the MultiThreadedDLL runtime
option(LIBMXF_SET_MSVC_RUNTIME "Enable setting MSVC runtime to MultiThreadedDLL" ON)
# Option to set to use the runtime
set(LIBMXF_SET_MSVC_RUNTIME "MD" CACHE STRING "Set MSVC debug/release runtime to 'MD' (MultiThreadedDLL), 'MT' (MultiThreaded) or 'default' (use the default)")
set_property(CACHE LIBMXF_SET_MSVC_RUNTIME PROPERTY STRINGS MD MT default)
endif()
37 changes: 27 additions & 10 deletions deps/libMXFpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
# Set policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)
# Set the policy CMP0091 to new to allow use of CMAKE_MSVC_RUNTIME_LIBRARY,
# unless it has already been set
if(POLICY CMP0091)
cmake_policy(GET CMP0091 CMP0091_value)
if(NOT CMP0091_value)
cmake_policy(SET CMP0091 NEW)
cmake_policy(GET CMP0091 CMP0091_value)
endif()
else()
set(CMP0091_value OLD)
endif()

project(libMXF++
Expand All @@ -14,25 +21,35 @@ project(libMXF++

include("${CMAKE_CURRENT_LIST_DIR}/cmake/options.cmake")

if(MSVC AND LIBMXFPP_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.15.0)
# cmake version >= 3.15: Use MultiThreadedDLL runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
if(MSVC AND CMP0091_value STREQUAL NEW)
if(LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "MD")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
elseif(LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "MT")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()

if(BUILD_SHARED_LIBS)
if(BUILD_SHARED_LIBS OR NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
# Ensure that static library code can be linked into the dynamic libraries (-fPIC compile option)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

set(CMAKE_CXX_STANDARD 11)

if(MSVC)
add_compile_options(/W3 /EHsc)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

if(LIBMXFPP_SET_MSVC_RUNTIME AND CMAKE_VERSION VERSION_LESS 3.15.0)
# cmake version < 3.15: Update compiler flags to use the MultiThreadedDLL runtime
if(CMP0091_value STREQUAL OLD AND NOT LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "default")
# Update compiler flags to use a particular runtime
macro(update_msvc_runtime_flags flags)
string(REGEX REPLACE "/MT" "/MD" ${flags} "${${flags}}")
if(LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "MD")
# Use MultiThreadedDLL runtime
string(REGEX REPLACE "/MT" "/MD" ${flags} "${${flags}}")
elseif(LIBMXFPP_SET_MSVC_RUNTIME STREQUAL "MT")
# Use MultiThreaded runtime
string(REGEX REPLACE "/MD" "/MT" ${flags} "${${flags}}")
endif()
endmacro()

update_msvc_runtime_flags(CMAKE_C_FLAGS)
Expand Down
5 changes: 3 additions & 2 deletions deps/libMXFpp/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ elseif(MSVC)
# Shared library currently not supported
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build using shared libraries")

# Option to set to use the MultiThreadedDLL runtime
option(LIBMXFPP_SET_MSVC_RUNTIME "Enable setting MSVC runtime to MultiThreadedDLL" ON)
# Option to set to use the runtime
set(LIBMXFPP_SET_MSVC_RUNTIME "MD" CACHE STRING "Set MSVC debug/release runtime to 'MD' (MultiThreadedDLL), 'MT' (MultiThreaded) or 'default' (use the default)")
set_property(CACHE LIBMXFPP_SET_MSVC_RUNTIME PROPERTY STRINGS MD MT default)
endif()