Skip to content

Commit

Permalink
cmake linting and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoftco committed Jan 9, 2024
1 parent 4a07def commit 942c6dc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
33 changes: 20 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
cmake_minimum_required(VERSION 3.15)
project(qasmtools VERSION 1.0 LANGUAGES CXX)
project(
qasmtools
VERSION 1.0
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
enable_testing()

#### qasmtools root directory
# qasmtools root directory
add_compile_definitions(PROJECT_ROOT_DIR="${PROJECT_SOURCE_DIR}")

#### Headers
# Headers
add_library(libqasmtools INTERFACE)
target_include_directories(libqasmtools INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
target_include_directories(
libqasmtools
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)

#### Enable OpenQASM 2.0 Specs
option(QASMTOOLS_QASM2_SPECS "Use OpenQASM 2.0 standard instead of Qiskit gate specifications" OFF)
if (${QASMTOOLS_QASM2_SPECS})
target_compile_definitions(libqasmtools INTERFACE -DQASMTOOLS_QASM2_SPECS=true)
else ()
target_compile_definitions(libqasmtools INTERFACE -DQASMTOOLS_QASM2_SPECS=false)
endif ()
# Enable OpenQASM 2.0 Specs
option(QASMTOOLS_QASM2_SPECS
"Use OpenQASM 2.0 standard instead of Qiskit gate specifications" OFF)
if(${QASMTOOLS_QASM2_SPECS})
target_compile_definitions(libqasmtools
INTERFACE -DQASMTOOLS_QASM2_SPECS=true)
else()
target_compile_definitions(libqasmtools
INTERFACE -DQASMTOOLS_QASM2_SPECS=false)
endif()

#### Unit testing
# Unit testing
add_subdirectory(${CMAKE_SOURCE_DIR}/unit_tests/)
24 changes: 13 additions & 11 deletions unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
include(GoogleTest)
set(TARGET_NAME "unit_tests")

#### Link Google Test dynamically if using MSVC
if (MSVC)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif ()
# Link Google Test dynamically if using MSVC
if(MSVC)
set(gtest_force_shared_crt
ON
CACHE BOOL "" FORCE)
endif()

add_subdirectory(libs/googletest-release-1.12.1 EXCLUDE_FROM_ALL)

Expand All @@ -15,14 +17,14 @@ aux_source_directory(tests/utils TEST_FILES)
add_executable(${TARGET_NAME} EXCLUDE_FROM_ALL tests/main.cpp)
add_dependencies(unit_tests ${TARGET_NAME})

if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13")
cmake_policy(SET CMP0076 NEW)
endif ()
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13")
cmake_policy(SET CMP0076 NEW)
endif()

#### Build all tests in ${TEST_FILES}
foreach (FILE ${TEST_FILES})
target_sources(${TARGET_NAME} PUBLIC ${FILE})
endforeach ()
# Build all tests in ${TEST_FILES}
foreach(file ${TEST_FILES})
target_sources(${TARGET_NAME} PUBLIC ${file})
endforeach()

target_link_libraries(${TARGET_NAME} PUBLIC gmock)
target_link_libraries(${TARGET_NAME} PUBLIC libqasmtools)
Expand Down

0 comments on commit 942c6dc

Please sign in to comment.