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

support for MinGW and cross compilation #37

Open
wants to merge 1 commit into
base: master
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
19 changes: 15 additions & 4 deletions vstgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function(vstgui_set_cxx_version target version)
set_property(TARGET ${target} PROPERTY CXX_STANDARD ${version})
set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${target} PROPERTY CMAKE_CXX_STANDARD_REQUIRED ON)
if(APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
target_compile_options(${target} PUBLIC "-stdlib=libc++")
endif()
endfunction(vstgui_set_cxx_version target version)
Expand Down Expand Up @@ -55,15 +55,15 @@ endif()
##########################################################################################
set(VSTGUI_COMPILE_DEFINITIONS_DEBUG "VSTGUI_LIVE_EDITING;DEBUG")
set(VSTGUI_COMPILE_DEFINITIONS_RELEASE "NDEBUG;RELEASE")
if(CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 7)
set(VSTGUI_LTO_COMPILER_FLAGS "-O3 -flto=thin")
else()
set(VSTGUI_LTO_COMPILER_FLAGS "-O3 -flto")
endif()
set(VSTGUI_LTO_LINKER_FLAGS "")
endif()
if(UNIX AND NOT CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|.*BSD)")
set(VSTGUI_LTO_COMPILER_FLAGS "-O3 -flto")
set(VSTGUI_LTO_LINKER_FLAGS "")
find_package(X11 REQUIRED)
Expand Down Expand Up @@ -110,6 +110,13 @@ set(CMAKE_STATIC_LINKER_FLAGS_RELEASELTO
"${CMAKE_STATIC_LINKER_FLAGS_RELEASE} ${VSTGUI_LTO_LINKER_FLAGS}"
)

if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND
(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_definitions(-D_WIN32_WINNT=0x601 -DWINVER=0x601)
add_definitions(-DWIN32_LEAN_AND_MEAN=1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar")
endif()

##########################################################################################
if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
Expand All @@ -136,7 +143,11 @@ endif()
add_subdirectory(lib)
add_subdirectory(uidescription)

if(UNIX AND NOT CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(VSTGUI_DISABLE_STANDALONE 1)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND
(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(VSTGUI_DISABLE_STANDALONE 1)
endif()

Expand Down
8 changes: 4 additions & 4 deletions vstgui/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,18 @@ set(${target}_linux_sources
)

##########################################################################################
if(CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(${target}_sources ${${target}_common_sources} ${${target}_mac_sources})
endif()

##########################################################################################
if(MSVC)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(${target}_sources ${${target}_common_sources} ${${target}_win32_sources})
endif()

##########################################################################################
# Linux
if(UNIX AND NOT CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|.*BSD)")
set(${target}_sources ${${target}_common_sources} ${${target}_linux_sources})
endif()

Expand All @@ -271,7 +271,7 @@ target_compile_definitions(${target} ${VSTGUI_COMPILE_DEFINITIONS})
vstgui_set_cxx_version(${target} 11)
vstgui_source_group_by_folder(${target})

if(UNIX AND NOT CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|.*BSD)")
target_include_directories(${target} PRIVATE ${X11_INCLUDE_DIR})
target_include_directories(${target} PRIVATE ${GTK3_INCLUDE_DIRS})
target_include_directories(${target} PRIVATE ${GTKMM3_INCLUDE_DIRS})
Expand Down
4 changes: 2 additions & 2 deletions vstgui/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ set(${target}_win32_sources
)

##########################################################################################
if(CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(${target}_sources ${${target}_common_sources} ${${target}_mac_sources})

set_source_files_properties(${${target}_sources} PROPERTIES
Expand All @@ -83,7 +83,7 @@ if(CMAKE_HOST_APPLE)
endif()

##########################################################################################
if(MSVC)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(${target}_sources ${${target}_common_sources} ${${target}_win32_sources})
endif()

Expand Down
18 changes: 13 additions & 5 deletions vstgui/tests/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ set(${target}_sources
)

##########################################################################################
if(CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(${target}_sources
${${target}_sources}
"${VSTGUI_TEST_BASE}lib/platform_helper_mac.mm"
Expand All @@ -93,16 +93,22 @@ if(CMAKE_HOST_APPLE)
endif()

##########################################################################################
if(MSVC)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(${target}_sources
${${target}_sources}
"${VSTGUI_TEST_BASE}lib/platform_helper_win32.cpp"
"${VSTGUI_TEST_BASE}../../vstgui_win32.cpp"
)
set(${target}_PLATFORM_LIBS
opengl32
gdiplus
shlwapi
windowscodecs
)
endif()

##########################################################################################
if(UNIX AND NOT CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|.*BSD)")
set(${target}_sources
${${target}_sources}
"${VSTGUI_TEST_BASE}lib/platform_helper_linux.cpp"
Expand All @@ -128,10 +134,12 @@ vstgui_set_cxx_version(${target} 14)
target_compile_definitions(${target} ${VSTGUI_COMPILE_DEFINITIONS} ENABLE_UNIT_TESTS=1 VSTGUI_LIVE_EDITING=1)
vstgui_source_group_by_folder(${target})

add_custom_command(TARGET ${target} POST_BUILD COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittests")
if(NOT CMAKE_CROSSCOMPILING)
add_custom_command(TARGET ${target} POST_BUILD COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittests")
endif()

##########################################################################################
if(UNIX AND NOT CMAKE_HOST_APPLE)
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|.*BSD)")
target_include_directories(${target} PRIVATE ${X11_INCLUDE_DIR})
target_include_directories(${target} PRIVATE ${GTK3_INCLUDE_DIRS})
target_include_directories(${target} PRIVATE ${GTKMM3_INCLUDE_DIRS})
Expand Down