Skip to content

Commit

Permalink
fix(cmake): infer win32 compilation flags
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo committed Mar 22, 2024
1 parent 8f2d04a commit d9f6651
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 11 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,14 @@ else()
set(MINIMAL_BUILD ON)

set(SYSDIG_FLAGS_WIN "-D_CRT_SECURE_NO_WARNINGS -DWIN32 -DMINIMAL_BUILD /EHsc /W3 /Zi")
set(SYSDIG_FLAGS_WIN_DEBUG "/MTd /Od")
set(SYSDIG_FLAGS_WIN_RELEASE "/MT")

if(CMAKE_VERSION VERSION_LESS 3.15.0)
set(SYSDIG_FLAGS_WIN_DEBUG "/MTd /Od")
set(SYSDIG_FLAGS_WIN_RELEASE "/MT")
else()
set(SYSDIG_FLAGS_WIN_DEBUG "/Od")
set(SYSDIG_FLAGS_WIN_RELEASE "")
endif()

set(CMAKE_C_FLAGS "${SYSDIG_FLAGS_WIN}")
set(CMAKE_CXX_FLAGS "${SYSDIG_FLAGS_WIN}")
Expand Down
61 changes: 52 additions & 9 deletions cmake/modules/yaml-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,61 @@ if(NOT USE_BUNDLED_DEPS)
else()
set(YAMLCPP_SRC "${PROJECT_BINARY_DIR}/yaml-cpp-prefix/src/yaml-cpp")
message(STATUS "Using bundled yaml-cpp in '${YAMLCPP_SRC}'")
set(YAMLCPP_INCLUDE_DIR "${YAMLCPP_SRC}/include")
if(NOT WIN32)
set(YAMLCPP_LIB "${YAMLCPP_SRC}/libyaml-cpp.a")
ExternalProject_Add(
yaml-cpp
URL "https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"
URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3"
BUILD_BYPRODUCTS ${YAMLCPP_LIB}
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DYAML_MSVC_SHARED_RT=Off
-DYAML_BUILD_SHARED_LIBS=Off
-DYAML_CPP_BUILD_TESTS=Off
-DYAML_CPP_BUILD_TOOLS=OFF
-DYAML_CPP_BUILD_CONTRIB=OFF
-DCMAKE_DEBUG_POSTFIX=''
BUILD_IN_SOURCE 1
INSTALL_COMMAND "")
else()
set(YAMLCPP_LIB "${YAMLCPP_SRC}/${CMAKE_BUILD_TYPE}/yaml-cpp.lib")
# see: https://cmake.org/cmake/help/latest/policy/CMP0091.html
if(CMAKE_VERSION VERSION_LESS 3.15.0)
ExternalProject_Add(
yaml-cpp
URL "https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"
URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3"
BUILD_BYPRODUCTS ${YAMLCPP_LIB}
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DYAML_MSVC_SHARED_RT=Off
-DYAML_BUILD_SHARED_LIBS=Off
-DYAML_CPP_BUILD_TESTS=Off
-DYAML_CPP_BUILD_TOOLS=OFF
-DYAML_CPP_BUILD_CONTRIB=OFF
-DCMAKE_DEBUG_POSTFIX=''
BUILD_IN_SOURCE 1
INSTALL_COMMAND "")
else()
ExternalProject_Add(
yaml-cpp
URL "https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"
URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3"
BUILD_BYPRODUCTS ${YAMLCPP_LIB}
CMAKE_ARGS
-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW
-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}
-DCMAKE_BUILD_TYPE=Release
-DYAML_MSVC_SHARED_RT=Off
-DYAML_BUILD_SHARED_LIBS=Off
-DYAML_CPP_BUILD_TESTS=Off
-DYAML_CPP_BUILD_TOOLS=OFF
-DYAML_CPP_BUILD_CONTRIB=OFF
-DCMAKE_DEBUG_POSTFIX=''
BUILD_IN_SOURCE 1
INSTALL_COMMAND "")
endif()
endif()
set(YAMLCPP_INCLUDE_DIR "${YAMLCPP_SRC}/include")
ExternalProject_Add(
yaml-cpp
URL "https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.7.0.tar.gz"
URL_HASH "SHA256=43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3"
BUILD_BYPRODUCTS ${YAMLCPP_LIB}
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DYAML_MSVC_SHARED_RT=Off -DYAML_BUILD_SHARED_LIBS=Off -DYAML_CPP_BUILD_TESTS=Off -DYAML_CPP_BUILD_TOOLS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF -DCMAKE_DEBUG_POSTFIX=''
BUILD_IN_SOURCE 1
INSTALL_COMMAND "")
endif()
2 changes: 2 additions & 0 deletions userspace/sysdig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ if(NOT WIN32)
include(ncurses)
endif() # NOT WIN32

include(zlib)

include_directories("${PROJECT_BINARY_DIR}/userspace/sinspui")
include_directories(../sinspui)
include_directories("${PROJECT_BINARY_DIR}/userspace/sysdig")
Expand Down

0 comments on commit d9f6651

Please sign in to comment.