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 1eee4b2 commit f7843e3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 41 deletions.
50 changes: 28 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,53 @@
cmake_minimum_required(VERSION 3.15)
project(qasm3tools VERSION 1.0 LANGUAGES CXX)
project(
qasm3tools
VERSION 1.0
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
enable_testing()

#### Windows issues with Microsoft Visual Studio
if (MSVC)
# Disable spurious warnings with MSVC (warning C4996)
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
endif ()
# Windows issues with Microsoft Visual Studio
if(MSVC)
# Disable spurious warnings with MSVC (warning C4996)
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
endif()

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

#### antlr4cpp library
# antlr4cpp library
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/antlr4cpp_runtime EXCLUDE_FROM_ALL)
# antlr4cpp headers
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/antlr4cpp_runtime/runtime/src)
include_directories(SYSTEM
${CMAKE_CURRENT_SOURCE_DIR}/antlr4cpp_runtime/runtime/src)

#### Libs
# Libs
include_directories(SYSTEM libs)

#### Headers
# Headers
add_library(libqasm3tools INTERFACE)
target_include_directories(libqasm3tools INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/antlr4cpp_generated/>)
target_include_directories(libqasm3tools INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
#target_link_libraries(libqasm3tools INTERFACE antlr4_static)
target_include_directories(
libqasm3tools
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/antlr4cpp_generated/>)
target_include_directories(
libqasm3tools
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
# target_link_libraries(libqasm3tools INTERFACE antlr4_static)
target_link_libraries(libqasm3tools INTERFACE antlr4_shared)

#### parser executable
# parser executable
set(PARSER "parser")
add_executable(${PARSER} src/parser.cpp)
target_link_libraries(${PARSER} PUBLIC libqasm3tools)

#### interpreter
# interpreter
option(WITH_INTERPRETER "Build interpreter. Must have Quantum++ installed" OFF)
if (${WITH_INTERPRETER})
include(cmake/interpreter.cmake)
endif ()
if(${WITH_INTERPRETER})
include(cmake/interpreter.cmake)
endif()

#### Unit testing
# Unit testing
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/)
5 changes: 2 additions & 3 deletions pyqasm3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package(qpp REQUIRED)

#### antlr4cpp library
# antlr4cpp library
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../antlr4cpp_runtime
${CMAKE_CURRENT_SOURCE_DIR}/../dist
EXCLUDE_FROM_ALL)
${CMAKE_CURRENT_SOURCE_DIR}/../dist EXCLUDE_FROM_ALL)
29 changes: 13 additions & 16 deletions unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
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)

aux_source_directory(tests TEST_FILES)
aux_source_directory(tests/parser TEST_FILES)
aux_source_directory(tests/utils TEST_FILES)

#### Link Google Test dynamically if using MSVC, and add bigobj option
if (MSVC)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif ()

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 libqasm3tools)

Expand Down

0 comments on commit f7843e3

Please sign in to comment.