Skip to content

Commit

Permalink
CMake: fix build on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
oltolm committed Jan 4, 2025
1 parent e18ada7 commit 3fc8214
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ cmake-build-*/
# Dependencies from .gitmodules
core/deps/breakpad/
core/deps/glslang/
.cache/
compile_commands.json
CMakeUserPresets.json
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ if(USE_OPENMP)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
if(MINGW)
target_link_libraries(${PROJECT_NAME} PRIVATE "-static -lgomp -lpthread")
target_link_libraries(${PROJECT_NAME} PRIVATE -lpthread)
target_link_options(${PROJECT_NAME} PRIVATE -fopenmp -static)
target_compile_options(${PROJECT_NAME} PRIVATE -fopenmp)
elseif(ANDROID)
# Reference: https://android.googlesource.com/platform/ndk/+/refs/heads/master/tests/device/openmp/CMakeLists.txt
Expand Down Expand Up @@ -1959,3 +1960,7 @@ if(${CMAKE_GENERATOR} MATCHES "^Xcode.*|^Visual Studio.*")
file(GLOB_RECURSE SRC_FILES *.h *.cpp *.c *.cc *.mm)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SRC_FILES})
endif()

if(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE Psapi)
endif()
23 changes: 23 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": 2,
"configurePresets": [
{
"name": "clang",
"generator": "Ninja",
"binaryDir": "build-clang",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "gcc",
"generator": "Ninja",
"binaryDir": "build-gcc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
}
]
}

0 comments on commit 3fc8214

Please sign in to comment.