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

[22704] Support compiler MSYS2-MinGW (backport #5600) #5635

Open
wants to merge 1 commit into
base: 2.10.x
Choose a base branch
from
Open
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
21 changes: 20 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,26 @@ endif()
###############################################################################
# Tools default setup
###############################################################################
option(COMPILE_TOOLS "Build tools" ON)
if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE COMPILER_MACHINE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(COMPILER_MACHINE MATCHES "mingw")
message(STATUS "Using MinGW compiler.")
option(COMPILE_TOOLS "Build tools" OFF)
add_definitions(-DMINGW_COMPILER=1)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-stringop-overread -Wno-builtin-macro-redefined -Wno-cast-function-type -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function -Wno-missing-field-initializers")
target_link_libraries(fastdds PUBLIC ws2_32 mswsock)
else()
message(STATUS "Using a GNU compiler on Windows but not MinGW.")
endif()
else()
message(STATUS "Not using a GNU compiler on Windows.")
option(COMPILE_TOOLS "Build tools" ON)
endif()

if(EPROSIMA_BUILD)
set(COMPILE_TOOLS ON)
Expand Down
82 changes: 82 additions & 0 deletions include/fastdds/fastdds_dll.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file fastdds_dll.hpp
*
*/

#ifndef FASTDDS_FASTDDS_DLL_H
#define FASTDDS_FASTDDS_DLL_H

#include <fastdds/config.hpp>

// normalize macros
#if !defined(FASTDDS_DYN_LINK) && !defined(FASTDDS_STATIC_LINK) \
&& !defined(EPROSIMA_ALL_DYN_LINK) && !defined(EPROSIMA_ALL_STATIC_LINK)
#define FASTDDS_STATIC_LINK
#endif // if !defined(FASTDDS_DYN_LINK) && !defined(FASTDDS_STATIC_LINK) && !defined(EPROSIMA_ALL_DYN_LINK) && !defined(EPROSIMA_ALL_STATIC_LINK)

#if defined(EPROSIMA_ALL_DYN_LINK) && !defined(FASTDDS_DYN_LINK)
#define FASTDDS_DYN_LINK
#endif // if defined(EPROSIMA_ALL_DYN_LINK) && !defined(FASTDDS_DYN_LINK)

#if defined(FASTDDS_DYN_LINK) && defined(FASTDDS_STATIC_LINK)
#error Must not define both FASTDDS_DYN_LINK and FASTDDS_STATIC_LINK
#endif // if defined(FASTDDS_DYN_LINK) && defined(FASTDDS_STATIC_LINK)

#if defined(EPROSIMA_ALL_NO_LIB) && !defined(FASTDDS_NO_LIB)
#define FASTDDS_NO_LIB
#endif // if defined(EPROSIMA_ALL_NO_LIB) && !defined(FASTDDS_NO_LIB)

// enable dynamic linking

#if defined(_WIN32)
#if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTDDS_DYN_LINK)
#if defined(MINGW_COMPILER)
#if defined(fastdds_EXPORTS)
#define FASTDDS_EXPORTED_API __declspec( dllexport )
#else
#define FASTDDS_EXPORTED_API __attribute__((visibility("default")))
#endif // FASTDDS_SOURCE
#else
#if defined(fastdds_EXPORTS)
#define FASTDDS_EXPORTED_API __declspec( dllexport )
#else
#define FASTDDS_EXPORTED_API __declspec( dllimport )
#endif // FASTDDS_SOURCE
#endif // if defined(MINGW_COMPILER)
#else
#define FASTDDS_EXPORTED_API
#endif // if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTDDS_DYN_LINK)
#else
#define FASTDDS_EXPORTED_API
#endif // _WIN32

// Auto linking.

#if !defined(FASTDDS_SOURCE) && !defined(EPROSIMA_ALL_NO_LIB) \
&& !defined(FASTDDS_NO_LIB)

// Set properties.
#define EPROSIMA_LIB_NAME fastdds

#if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTDDS_DYN_LINK)
#define EPROSIMA_DYN_LINK
#endif // if defined(EPROSIMA_ALL_DYN_LINK) || defined(FASTDDS_DYN_LINK)

#include <fastdds/fastdds_auto_link.hpp>
#endif // auto-linking disabled

#endif // FASTDDS_FASTDDS_DLL_H
5 changes: 5 additions & 0 deletions include/fastrtps/utils/TimedMutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528
#include <mutex>
#elif defined(MINGW_COMPILER)
#include <mutex>
#else
#include <thread>
extern int clock_gettime(
Expand All @@ -47,6 +49,9 @@ namespace fastrtps {
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528
using TimedMutex = std::timed_mutex;
using RecursiveTimedMutex = std::recursive_timed_mutex;
#elif defined(MINGW_COMPILER)
using TimedMutex = std::timed_mutex;
using RecursiveTimedMutex = std::recursive_timed_mutex;
#else
class TimedMutex
{
Expand Down
Loading