Skip to content

Commit

Permalink
okay word
Browse files Browse the repository at this point in the history
  • Loading branch information
lyndskg committed Jan 6, 2024
1 parent 9f3fdf3 commit cd77a2d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
23 changes: 12 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ cmake_policy(SET CMP0146 OLD)

set(CMAKE_VERBOSE_MAKEFILE on)

# Set GTest root directory
set(GTEST_ROOT "/opt/homebrew/Cellar/googletest/1.14.0" CACHE PATH "Google Test root directory")

# Project configuration
project(black-scholes-cpp VERSION 1.0 LANGUAGES CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64")
Expand All @@ -18,12 +21,12 @@ message(STATUS "C++ Compiler Flags: ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Locate the Google Test library
find_package(GTest REQUIRED)

if(NOT GTest_FOUND)
message(FATAL_ERROR "Google Test not found. Please make sure it is installed.")
endif()
## Locate the Google Test library
#find_package(GTest REQUIRED)
#
#if(NOT GTest_FOUND)
# message(FATAL_ERROR "Google Test not found. Please make sure it is installed.")
#endif()

# Add subdirectories
add_subdirectory(gtest) # Assuming Google Test is in the 'gtest' directory
Expand All @@ -46,8 +49,8 @@ target_include_directories(blackScholesLibrary
# Set compiler features
target_compile_features(blackScholesLibrary PUBLIC cxx_std_20)

# Link against Threads library (if needed)
target_link_libraries(blackScholesLibrary PRIVATE Threads::Threads)
## Link against Threads library (if needed)
#target_link_libraries(blackScholesLibrary PRIVATE Threads::Threads)

# Add the main executable
add_executable(black_scholes_cpp ${SOURCES})
Expand All @@ -70,11 +73,9 @@ target_compile_features(blackScholesLibrary PUBLIC cxx_std_20)
# Link against Google Test, blackScholesLibrary, Threads, and other necessary libraries
target_link_libraries(black_scholes_cpp
PRIVATE
GTest::GTest
GTest::Main
GTest::gtest_main
blackScholesLibrary
curl
Threads::Threads
)

# Optionally, enable CTest for running tests with 'make test'
Expand Down
9 changes: 3 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ cmake_policy(SET CMP0144 OLD)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Locate the Google Test library
find_package(GTest REQUIRED)

# Add the include directories for Google Test
include_directories(${GTEST_INCLUDE_DIRS})

Expand All @@ -26,10 +23,10 @@ include_directories(src)
add_executable(bsm main.cpp)

# Link against your library and Google Test
target_link_libraries(bsm PRIVATE GTest::GTest GTest::Main blackScholesLibrary)
target_link_libraries(bsm PRIVATE GTest::gtest_main blackScholesLibrary)

# Include directories for the main application
target_include_directories(bsm PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/black-scholes-cpp)

# Link against the Threads library (if needed)
target_link_libraries(bsm PRIVATE Threads::Threads)
## Link against the Threads library (if needed)
#target_link_libraries(bsm PRIVATE Threads::Threads)
23 changes: 16 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,22 @@ if(APPLE)
set(THREADS_PREFER_PTHREAD_FLAG ON)
endif()

# Find and include Google Test
find_package(GTest REQUIRED)
include(FetchContent)
include(GoogleTest)

if(NOT GTest_FOUND)
message(FATAL_ERROR "Google Test not found. Please make sure it is installed.")
endif()
# Fetch GTest
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
FetchContent_MakeAvailable(googletest)

## Find and include Google Test
#find_package(GTest REQUIRED)
#
#if(NOT GTest_FOUND)
# message(FATAL_ERROR "Google Test not found. Please make sure it is installed.")
#endif()

# Add a test executable
add_executable(black_scholes_cpp_test
Expand All @@ -45,8 +55,7 @@ target_include_directories(black_scholes_cpp_test PRIVATE ${GTEST_INCLUDE_DIRS})
# Link against Google Test, blackScholesLibrary, and other necessary libraries
target_link_libraries(black_scholes_cpp_test
PRIVATE
GTest::GTest
GTest::Main
GTest::gtest_main
blackScholesLibrary
curl
)
Expand Down

0 comments on commit cd77a2d

Please sign in to comment.