Skip to content

Commit

Permalink
Install opts notest (#172)
Browse files Browse the repository at this point in the history
* allow no building of tests

* change default

* just use setup.py install

* fix install

* remove HWY_DLLEXPORT
  • Loading branch information
hmacdope authored Oct 16, 2024
1 parent 904b3a6 commit 12930af
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 93 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/make_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,35 @@ jobs:
# run python API tests
run: pytest distopia/tests


external_hwy_no_test:
# A conda install, which relies purely on pyproject.toml contents
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: mamba-org/setup-micromamba@v1
with:
environment-file: devtools/conda_envs/distopia_${{ matrix.os }}.yaml
environment-name: distopia
create-args: >-
python==${{ matrix.python-version }}
- name: install libhwy
run: micromamba install -c conda-forge libhwy

- name: check_env
run: |
which python
python -m pip list
- name: build
run: python setup.py build -- -DDISTOPIA_BUILD_TESTS=OFF -DDISTOPIA_USE_EXTERNAL_HWY=ON
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ include_directories(${PROJECT_SOURCE_DIR}/libdistopia/include)

# setup an option for using external HWY
option(DISTOPIA_USE_EXTERNAL_HWY "Use external HWY" OFF)
option(DISTOPIA_BUILD_TESTS "Build tests" ON)

# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
Expand Down
66 changes: 35 additions & 31 deletions libdistopia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
set(HWY_ENABLE_TESTS OFF CACHE BOOL "Enable HWY tests" FORCE)


set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Enable googlebench tests" FORCE)
add_subdirectory("googlebench")


set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

Expand All @@ -28,45 +27,50 @@ else()
add_subdirectory("highway")
target_link_libraries(libdistopia PRIVATE hwy)
endif()


add_executable(bench)
target_sources(bench PRIVATE "test/bench.cpp")
target_link_libraries(bench PUBLIC benchmark::benchmark)
target_link_libraries(bench PUBLIC libdistopia)
target_include_directories(bench PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if(DISTOPIA_BUILD_TESTS)

set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Enable googlebench tests" FORCE)
add_subdirectory("googlebench")

Include(GoogleTest)
add_subdirectory("googletest")
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include_directories(${gmock_SOURCE_DIR}/include ${gmock_SOURCE_DIR})
add_executable(bench)
target_sources(bench PRIVATE "test/bench.cpp")
target_link_libraries(bench PUBLIC benchmark::benchmark)
target_link_libraries(bench PUBLIC libdistopia)
target_include_directories(bench PUBLIC ${CMAKE_CURRENT_LIST_DIR})


add_executable(test)
target_sources(test PRIVATE "test/test.cpp")
target_link_libraries(test PUBLIC gtest gtest_main)
target_link_libraries(test PUBLIC gmock gmock_main)
Include(GoogleTest)
add_subdirectory("googletest")
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include_directories(${gmock_SOURCE_DIR}/include ${gmock_SOURCE_DIR})

target_link_libraries(test PUBLIC libdistopia)
target_include_directories(test PUBLIC ${CMAKE_SOURCE_DIR})
gtest_discover_tests(test WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

add_executable(test)
target_sources(test PRIVATE "test/test.cpp")
target_link_libraries(test PUBLIC gtest gtest_main)
target_link_libraries(test PUBLIC gmock gmock_main)

add_executable(targets)
target_sources(targets PRIVATE "test/targets.cpp")
target_link_libraries(targets PUBLIC libdistopia)
target_include_directories(targets PUBLIC ${CMAKE_SOURCE_DIR})
target_link_libraries(test PUBLIC libdistopia)
target_include_directories(test PUBLIC ${CMAKE_SOURCE_DIR})
gtest_discover_tests(test WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

add_executable(test_mda_match)
target_sources(test_mda_match PRIVATE "test/test_mda_match.cpp")
target_link_libraries(test_mda_match PUBLIC gtest gtest_main)
target_link_libraries(test PUBLIC gmock gmock_main)
target_link_libraries(test_mda_match PUBLIC libdistopia)
target_include_directories(test_mda_match PUBLIC ${CMAKE_SOURCE_DIR})
gtest_discover_tests(test_mda_match WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

add_executable(targets)
target_sources(targets PRIVATE "test/targets.cpp")
target_link_libraries(targets PUBLIC libdistopia)
target_include_directories(targets PUBLIC ${CMAKE_SOURCE_DIR})

add_executable(test_mda_match)
target_sources(test_mda_match PRIVATE "test/test_mda_match.cpp")
target_link_libraries(test_mda_match PUBLIC gtest gtest_main)
target_link_libraries(test PUBLIC gmock gmock_main)
target_link_libraries(test_mda_match PUBLIC libdistopia)
target_include_directories(test_mda_match PUBLIC ${CMAKE_SOURCE_DIR})
gtest_discover_tests(test_mda_match WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

# cmake will append the name lib already , avoid liblibdistopia
set_target_properties(libdistopia PROPERTIES OUTPUT_NAME distopia)
Expand Down
Loading

0 comments on commit 12930af

Please sign in to comment.