File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.25 )
2+
3+ project (cpuscope VERSION 0.1.0 LANGUAGES CXX )
4+
5+ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
6+ message (FATAL_ERROR "In-source builds are not allowed. Please use a separate build directory." )
7+ endif ()
8+
9+ option (CI "Enable CI build mode and treat warnings as errors" OFF )
10+ option (ENABLE_MARCH_NATIVE "Enable -march=native optimization" OFF )
11+
12+ set (CMAKE_CXX_STANDARD 20)
13+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
14+ set (CMAKE_CXX_EXTENSIONS OFF )
15+
16+ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
17+ set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
18+ endif ()
19+
20+ if (CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$" )
21+ add_compile_options (-Wall -Wextra -Wpedantic )
22+ if (CI)
23+ add_compile_options (-Werror )
24+ endif ()
25+ if (ENABLE_MARCH_NATIVE)
26+ add_compile_options (-march=native )
27+ endif ()
28+ endif ()
29+
30+ if (NOT CMAKE_CXX_FLAGS MATCHES "-O[0-3s]" )
31+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2" )
32+ endif ()
33+
34+ find_package (Threads REQUIRED )
35+ find_package (LLVM QUIET )
36+
37+ add_subdirectory (src )
38+ add_subdirectory (tests )
Original file line number Diff line number Diff line change 1+ add_library (cpuscope_lib STATIC
2+ cpuscope_lib.cpp
3+ cpuscope_lib.hpp
4+ )
5+
6+ target_include_directories (cpuscope_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )
7+
8+ target_link_libraries (cpuscope_lib PUBLIC Threads::Threads )
9+
10+ if (LLVM_FOUND)
11+ message (STATUS "Optional LLVM integration enabled: ${LLVM_PACKAGE_VERSION} " )
12+ target_link_libraries (cpuscope_lib PUBLIC LLVM )
13+ else ()
14+ message (STATUS "LLVM not found; continuing without optional LLVM support." )
15+ endif ()
16+
17+ target_compile_features (cpuscope_lib PUBLIC cxx_std_20 )
18+
19+ add_executable (cpuscope_cli main.cpp )
20+
21+ target_link_libraries (cpuscope_cli PRIVATE cpuscope_lib )
22+
23+ set_target_properties (cpuscope_cli PROPERTIES
24+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
25+ )
Original file line number Diff line number Diff line change 1+ #include " cpuscope_lib.hpp"
2+
3+ // Implementation is header-only for the initial placeholder functionality.
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < format>
4+ #include < span>
5+ #include < string>
6+ #include < string_view>
7+ #include < vector>
8+
9+ namespace cpuscope {
10+
11+ inline std::string format_message (std::span<const std::string_view> args)
12+ {
13+ return std::format (" CPUScope CLI placeholder: {} arguments received." , args.size ());
14+ }
15+
16+ } // namespace cpuscope
Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ #include < vector>
3+ #include < string_view>
4+
5+ #include " cpuscope_lib.hpp"
6+
7+ int main (int argc, char * argv[])
8+ {
9+ std::vector<std::string_view> args;
10+ args.reserve (argc);
11+ for (int i = 0 ; i < argc; ++i) {
12+ args.emplace_back (argv[i]);
13+ }
14+
15+ std::cout << cpuscope::format_message (args) << ' \n ' ;
16+ return 0 ;
17+ }
Original file line number Diff line number Diff line change 1+ add_executable (cpuscope_tests test_main.cpp )
2+
3+ target_link_libraries (cpuscope_tests PRIVATE cpuscope_lib )
4+
5+ set_target_properties (cpuscope_tests PROPERTIES
6+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
7+ )
8+
9+ add_test (NAME cpuscope_tests COMMAND cpuscope_tests )
Original file line number Diff line number Diff line change 1+ int main ()
2+ {
3+ // Placeholder test target. GoogleTest integration will be added in a future issue.
4+ return 0 ;
5+ }
You can’t perform that action at this time.
0 commit comments