Skip to content

Commit

Permalink
#486 Attempts to fix cmake build on windows, msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
OlekRaymond committed Jan 7, 2025
1 parent da9c771 commit de1b863
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ name: CMake

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
Expand Down Expand Up @@ -41,7 +38,7 @@ jobs:
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
if [ ${{ matrix.os }} == 'windows-latest' ]; then
cmake -DTEST=ON -Dgtest_disable_pthreads=ON -B ${{github.workspace}}/build
cmake -DTEST=ON -Dgtest_disable_pthreads=ON -B ./build
else
cmake -DTEST=ON -B ${{github.workspace}}/build
fi;
Expand Down
25 changes: 13 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ if(DEBUG)
)
endif(DEBUG)

option(SANITIZE "Enable Sanitize" OFF)
if(SANITIZE)
add_compile_options(
-fsanitize=address
-fsanitize=leak
)
add_link_options(
-fsanitize=address
-fsanitize=leak
)
endif(SANITIZE)
if (NOT MSVC)
option(SANITIZE "Enable Sanitize" OFF)
if(SANITIZE)
add_compile_options(
-fsanitize=address
-fsanitize=leak
)
add_link_options(
-fsanitize=address
-fsanitize=leak
)
endif(SANITIZE)
endif()

# set up CPM.cmake
if(CPM_SOURCE_CACHE)
Expand All @@ -52,5 +54,4 @@ add_subdirectory(test)
add_subdirectory(benchmark)
add_subdirectory(examples)

#install(FILES include/Graph.hpp DESTINATION /usr/include)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include)
46 changes: 25 additions & 21 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
option(CODE_COVERAGE "Enable coverage reporting" OFF)
option(CMAKE_USE_WIN32_THREADS_INIT "using WIN32 threads" ON)
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON)

# Force dynamic linking since MSVC now links C runtimes dynamically by default
set(gtest_force_shared_crt on)

if(CODE_COVERAGE)
message( "Code Coverage Enabled" )
add_compile_options(
-O0 #no optimization
-g #generate debug info
--coverage #set coverage flag
-fprofile-arcs
-ftest-coverage
-fPIC
)
link_libraries(
"gcov"
"-fprofile-arcs"
"--coverage"
)
if (NOT MSVC)
option(CODE_COVERAGE "Enable coverage reporting" OFF)
if(CODE_COVERAGE)
message( "Code Coverage Enabled" )
add_compile_options(
-O0 #no optimization
-g #generate debug info
--coverage #set coverage flag
-fprofile-arcs
-ftest-coverage
-fPIC
)
link_libraries(
"gcov"
"-fprofile-arcs"
"--coverage"
)

endif(CODE_COVERAGE)
endif(CODE_COVERAGE)
endif()

option(TEST "Enable Test" OFF)
if(TEST)
include(${CPM_DOWNLOAD_LOCATION})
add_compile_options(
-Wall
-Wextra
)
if (NOT MSVC)
add_compile_options(
-Wall
-Wextra
)
endif()

CPMAddPackage(
NAME googletest
Expand Down

0 comments on commit de1b863

Please sign in to comment.