diff --git a/CMakeLists.txt b/CMakeLists.txt index f258c9d..134670d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25) option(OCCUTILS_BUILD_TESTS "Build tests" OFF) if (OCCUTILS_BUILD_TESTS) - list(APPEND VCPKG_MANIFEST_FEATURES "tests") + list(APPEND VCPKG_MANIFEST_FEATURES "tests") endif () set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_LIST_DIR}/vcpkg/triplets" CACHE STRING "") @@ -16,7 +16,7 @@ set(cmake_package_name occutils CACHE INTERNAL "") # Set default build to release if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE) endif () # Compiler config @@ -25,20 +25,20 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # make sure __cplusplus is defined when using msvc and enable parallel build if (MSVC) - string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus /MP") + string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus /MP") endif () set(CMAKE_CXX_EXTENSIONS OFF) -if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS") - set(CMAKE_CXX_EXTENSIONS ON) +if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS" OR (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")) + set(CMAKE_CXX_EXTENSIONS ON) endif () # These commands only run if this is the main project if (CMAKE_PROJECT_NAME STREQUAL "occutils") - # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to - # make it prominent in the GUI. - option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) + # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to + # make it prominent in the GUI. + option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) endif () # warning options @@ -62,22 +62,22 @@ find_package(GTest CONFIG REQUIRED) cxx_library(${PROJECT_NAME} src/occutils-all.cc) target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE - ${OpenCASCADE_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} - ) + ${OpenCASCADE_INCLUDE_DIR} + ${Boost_INCLUDE_DIRS} + ) if (OCCUTILS_BUILD_WARNINGS) - target_enable_warnings(${PROJECT_NAME}) + target_enable_warnings(${PROJECT_NAME}) endif () # If the CMake version supports it, attach header directory information # to the targets for when we are part of a parent build (ie being pulled # in via add_subdirectory() rather than being a standalone build). if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11") - target_include_directories(${PROJECT_NAME} PUBLIC - "$" - "$/${CMAKE_INSTALL_INCLUDEDIR}>" - ) + target_include_directories(${PROJECT_NAME} PUBLIC + "$" + "$/${CMAKE_INSTALL_INCLUDEDIR}>" + ) endif () # Configure install @@ -110,7 +110,7 @@ install(EXPORT ${PROJECT_NAME} DESTINATION ${export_dest_dir} NAMESPACE ${PROJEC # Configure package config file configure_package_config_file("${project_config_in}" "${project_config_out}" - INSTALL_DESTINATION ${export_dest_dir}) + INSTALL_DESTINATION ${export_dest_dir}) # Write version config file write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion) @@ -120,9 +120,9 @@ install(FILES "${project_config_out}" "${version_config_file}" DESTINATION "${ex # Testing if (OCCUTILS_BUILD_TESTS) - message(STATUS "Generating tests") - enable_testing() - add_subdirectory(test) + message(STATUS "Generating tests") + enable_testing() + add_subdirectory(test) endif () # Packaging diff --git a/vcpkg/ports/opencascade/portfile.cmake b/vcpkg/ports/opencascade/portfile.cmake index 97d6b58..cb1ef96 100644 --- a/vcpkg/ports/opencascade/portfile.cmake +++ b/vcpkg/ports/opencascade/portfile.cmake @@ -11,6 +11,14 @@ vcpkg_from_github( fix-depend-freetype.patch ) +# message("VCPKG_CMAKE_SYSTEM_NAME: ${VCPKG_CMAKE_SYSTEM_NAME}") + +# MinGW compiler does generate import libraries (.dll.a files) for DLLs on Windows. +# Suppresses Warning: Import libraries were not present (only looking for ".lib" files) +if (WIN32 AND VCPKG_CMAKE_SYSTEM_NAME STREQUAL "MinGW") + set(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled) +endif () + if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) set(BUILD_TYPE "Shared") else () @@ -26,7 +34,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS # VTK option in opencascade not currently supported because only 6.1.0 is supported but vcpkg has >= 9.0 -# We turn off BUILD_MODULE_Draw as it requires TCL 8.6 and TK 8.6 specifically which conflicts with vcpkg only having TCL 9.0 +# We turn off BUILD_MODULE_Draw as it requires TCL 8.6 and TK 8.6 specifically which conflicts with vcpkg only having TCL 9.0 # And pre-built ActiveTCL binaries are behind a marketing wall :( # We use the Unix install layout for Windows as it matches vcpkg vcpkg_cmake_configure( @@ -69,7 +77,7 @@ foreach (file_name IN LISTS files) endforeach () # Remove libd to lib, libd just has cmake files we dont want too -if (WIN32) +if (WIN32 AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "MinGW") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib") file(RENAME "${CURRENT_PACKAGES_DIR}/debug/libd" "${CURRENT_PACKAGES_DIR}/debug/lib") endif () @@ -79,7 +87,7 @@ file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) # debug creates libd and bind directories that need moving - if (WIN32) + if (WIN32 AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "MinGW") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin") file(RENAME "${CURRENT_PACKAGES_DIR}/debug/bind" "${CURRENT_PACKAGES_DIR}/debug/bin") endif () diff --git a/vcpkg/triplets/x64-mingw-static.cmake b/vcpkg/triplets/x64-mingw-static.cmake new file mode 100644 index 0000000..abc43ce --- /dev/null +++ b/vcpkg/triplets/x64-mingw-static.cmake @@ -0,0 +1,10 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_ENV_PASSTHROUGH PATH) + +set(VCPKG_CMAKE_SYSTEM_NAME MinGW) + +if (PORT MATCHES "opencascade") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif ()