Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoftco committed Feb 14, 2024
1 parent 8c83665 commit b384f0c
Show file tree
Hide file tree
Showing 259 changed files with 99 additions and 110,701 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: GitHub actions

on:
push:
branches: [ "**" ]
branches: ["**"]
pull_request:
branches: [ "**" ]
branches: ["**"]

env:
BUILD_TYPE: Debug
Expand All @@ -13,7 +13,7 @@ jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
export CPATH=$LIBRARY_PATH:/usr/local/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
fi
cmake --build build --target unit_tests
cmake --build build --target build/unit_tests
- name: Run unit tests
run: ctest --test-dir build
Expand Down
5 changes: 4 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Version 3.5 - xx February 2024
- Removed pybind11 and GoogleTest dependencies; if not detected, they are
installed automatically as dependencies by CMake
- Bumped GoogleTest version to HEAD latest (as recommended by Google,
https://github.com/google/googletest?tab=readme-ov-file#live-at-head)
- All header files are moved into "[include/staq]", so to include staq
headers one now must #include "staq/<header>.hpp". This change was made
for the sake of making the include statements look "uniform" in both
non-installed (compiling without having staq installed) and installed
(compiling with staq installed headers) modes.
- Integrated the 'staq_ionq' OpenQASM2 -> IonQ transpiler into pystaq
- Bumped GoogleTest version to 1.14.0

Version 3.4 - 1 December 2023
- When configuring staq with 'cmake -B build -DINSTALL_SOURCES=ON',
Expand Down
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ add_compile_definitions(PROJECT_ROOT_DIR="${PROJECT_SOURCE_DIR}")
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(
FATAL_ERROR
"In-source builds not allowed. Please instruct CMake to use an out-of-source build, e.g.,
cmake --build build [...]
"In-source builds not allowed. Please instruct CMake to use an\
out-of-source build, e.g.,
cmake -B build && cmake --build build
You may need to remove CMakeCache.txt.")
endif()

Expand Down Expand Up @@ -70,10 +71,11 @@ target_include_directories(
libstaq INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libs>
$<INSTALL_INTERFACE:include/staq/third_party>)

# pystaq (only if Python development kit is detected)
# pystaq and pybind11 (only if the Python development kit is detected)
find_package(Python3 QUIET COMPONENTS Interpreter Development)
if(${Python3_FOUND})
include(cmake/staq_pystaq.cmake)
include(cmake/pybind11.cmake)
include(cmake/pystaq.cmake)
endif()

# Enable OpenQASM 2.0 Specs
Expand All @@ -92,10 +94,11 @@ set(COMPILER "staq")
add_executable(${COMPILER} ${PROJECT_SOURCE_DIR}/src/staq/main.cpp)
target_link_libraries(${COMPILER} PUBLIC libstaq)

# Additional command line tools add_subdirectory(src/tools)
# Additional command line tools
add_subdirectory(src/tools)

# Unit testing
add_subdirectory(${CMAKE_SOURCE_DIR}/unit_tests/)
add_subdirectory(${CMAKE_SOURCE_DIR}/unit_tests/ EXCLUDE_FROM_ALL SYSTEM)

# Enable all warnings for GNU gcc and Clang/AppleClang
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_CXX_COMPILER_ID}
Expand Down
19 changes: 19 additions & 0 deletions cmake/grid_synth.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(BUILD_GRID_SYNTH OFF)
if(MSVC)
find_package(PkgConfig)
if(PkgConfig_FOUND)
# gmp, gmpxx
pkg_check_modules(gmp IMPORTED_TARGET gmp)
pkg_check_modules(gmpxx IMPORTED_TARGET gmpxx)
if(gmp_FOUND AND gmpxx_FOUND)
set(BUILD_GRID_SYNTH ON)
add_compile_options("-DEXPR_GMP")
endif()
endif()
else()
find_package(GMP)
if(GMP_FOUND)
set(BUILD_GRID_SYNTH ON)
add_compile_options("-DEXPR_GMP")
endif()
endif()
17 changes: 17 additions & 0 deletions cmake/pybind11.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
message(STATUS "Detecting pybind11...")
find_package(pybind11 CONFIG)
if(NOT pybind11_FOUND)
# Install pybind11 on demand
include(FetchContent)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
message(STATUS "pybind11 not detected, fetching pybind11...")
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11
GIT_TAG master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)
FetchContent_MakeAvailable(pybind11)
set(PYBIND11_INCLUDE_DIRS ${pybind11_SOURCE_DIR})
endif()
message(STATUS "Detected pybind11 in: ${PYBIND11_INCLUDE_DIRS}")
4 changes: 2 additions & 2 deletions cmake/staq_pystaq.cmake → cmake/pystaq.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# LSP and CMake support for pystaq

# pybind11
include_directories(SYSTEM libs/)
include_directories(SYSTEM ${PYBIND11_INCLUDE_DIRS})
target_include_directories(
libstaq INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libs/>)
libstaq INTERFACE $<BUILD_INTERFACE:${PYBIND11_INCLUDE_DIRS}/include/>)

# Python development
target_include_directories(libstaq
Expand Down
19 changes: 0 additions & 19 deletions cmake/staq_grid_synth.cmake

This file was deleted.

16 changes: 8 additions & 8 deletions cmake/staq_msvc.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#### MSVC lack of pthread.h
if (MSVC)
include_directories(SYSTEM ${STAQ_INSTALL_DIR}/third_party/pthreadwin32)
endif ()
# MSVC lack of pthread.h
if(MSVC)
include_directories(SYSTEM ${STAQ_INSTALL_DIR}/third_party/pthreadwin32)
endif()

#### MSVC bigobj
if (MSVC)
add_compile_options(-bigobj)
endif ()
# MSVC bigobj
if(MSVC)
add_compile_options(-bigobj)
endif()
23 changes: 12 additions & 11 deletions cmake/staq_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
IF(POLICY CMP0012)
CMAKE_POLICY(SET CMP0012 NEW)
ENDIF()
if(POLICY CMP0012)
cmake_policy(SET CMP0012 NEW)
endif()

if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
message(
FATAL_ERROR
"Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif()

file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
Expand All @@ -14,8 +16,7 @@ foreach(file ${files})
execute_process(
COMMAND @CMAKE_COMMAND@ -E rm $ENV{DESTDIR}${file}
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
RESULT_VARIABLE rm_retval)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
Expand All @@ -25,10 +26,10 @@ foreach(file ${files})
endforeach()

if(NOT "@MSVC@")
message(STATUS "Removing @CMAKE_INSTALL_PREFIX@/lib/cmake/@PROJECT_NAME@")
if("@INSTALL_SOURCES@")
message(STATUS "Removing @STAQ_INSTALL_DIR@")
endif()
message(STATUS "Removing @CMAKE_INSTALL_PREFIX@/lib/cmake/@PROJECT_NAME@")
if("@INSTALL_SOURCES@")
message(STATUS "Removing @STAQ_INSTALL_DIR@")
endif()
else()
message(STATUS "Removing @CMAKE_INSTALL_PREFIX@")
message(STATUS "Removing @CMAKE_INSTALL_PREFIX@")
endif()
1 change: 1 addition & 0 deletions pystaq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ cnot_resynth
map
get_resources
output_cirq
output_ionq
output_projectq
output_qsharp
output_quil
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _load_shared_obj(name):
ext_modules = [
Pybind11Extension(
"pystaq",
["pystaq/src/staq_wrapper.cpp"],
["pystaq/staq_wrapper.cpp"],
extra_compile_args=extra_compile_args,
extra_link_args=extra_links_args,
cxx_std=17,
Expand Down
10 changes: 5 additions & 5 deletions src/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ file(GLOB FILENAMES *.cpp)

add_custom_target(tools COMMENT "Build all binary tools.")

include(${CMAKE_SOURCE_DIR}/cmake/staq_grid_synth.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/grid_synth.cmake)

foreach(filename ${FILENAMES})
get_filename_component(basename ${filename} NAME_WE)
foreach(file ${FILENAMES})
get_filename_component(basename ${file} NAME_WE)
if(${BUILD_GRID_SYNTH})
add_executable("staq_${basename}" ${filename})
add_executable("staq_${basename}" ${file})
if(MSVC)
target_link_libraries(staq_${basename} PUBLIC PkgConfig::gmp
PkgConfig::gmpxx)
Expand All @@ -18,7 +18,7 @@ foreach(filename ${FILENAMES})
if(${basename} STREQUAL "grid_synth" OR ${basename} STREQUAL "qasm_synth")
continue()
endif()
add_executable("staq_${basename}" ${filename})
add_executable("staq_${basename}" ${file})
endif()
target_link_libraries(staq_${basename} PUBLIC libstaq)
add_dependencies(tools staq_${basename})
Expand Down
24 changes: 17 additions & 7 deletions unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@ include(GoogleTest)
set(TARGET_NAME "unit_tests")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Link Google Test dynamically if using MSVC
# GoogleTest
include(FetchContent)
message(STATUS "Fetching GoogleTest...")
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)
# For Windows: Prevent overriding the parent project's compiler/linker settings,
# and add bigobj option
if(MSVC)
add_compile_options(-bigobj)
set(gtest_force_shared_crt
ON
CACHE BOOL "" FORCE)
if(MSVC_VERSION GREATER_EQUAL 1914)
add_compile_options("/Zc:__cplusplus")
endif()
endif()

add_subdirectory(libs/googletest-1.14.0 EXCLUDE_FROM_ALL SYSTEM)
FetchContent_MakeAvailable(googletest)

aux_source_directory(tests TEST_FILES)
aux_source_directory(tests/parser TEST_FILES)
Expand All @@ -23,7 +33,7 @@ aux_source_directory(tests/transformations TEST_FILES)
aux_source_directory(tests/mapping TEST_FILES)
aux_source_directory(tests/synthesis TEST_FILES)

include(${CMAKE_SOURCE_DIR}/cmake/staq_grid_synth.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/grid_synth.cmake)
if(${BUILD_GRID_SYNTH})
aux_source_directory(tests/grid_synth TEST_FILES)
endif()
Expand All @@ -36,9 +46,9 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13")
endif()

# Build all tests in ${TEST_FILES}
foreach(filename ${TEST_FILES})
get_filename_component(basename ${filename} NAME_WE)
target_sources(${TARGET_NAME} PUBLIC ${filename})
foreach(file ${TEST_FILES})
get_filename_component(basename ${file} NAME_WE)
target_sources(${TARGET_NAME} PUBLIC ${file})
endforeach()

target_link_libraries(${TARGET_NAME} PUBLIC gmock libstaq)
Expand Down
4 changes: 0 additions & 4 deletions unit_tests/libs/googletest-1.14.0/.clang-format

This file was deleted.

This file was deleted.

Loading

0 comments on commit b384f0c

Please sign in to comment.