Verified Commit a3c19c9c authored by nagayama15's avatar nagayama15

build: import fmtlib and gtest

parent 9575b7cb
......@@ -18,7 +18,10 @@ project(wasm-watermarker VERSION 0.1.0 LANGUAGES CXX)
enable_testing()
find_package(Boost 1.65.0 REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
include(ExternalProject)
include(cmake/boost.cmake)
include(cmake/fmt.cmake)
include(cmake/googletest.cmake)
add_subdirectory(src)
add_subdirectory(test)
find_package(Boost 1.65.0 REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
ExternalProject_Add(fmt
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG "master"
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/fmt"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/fmt/src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/fmt/build"
STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/fmt/stamp"
UPDATE_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
CMAKE_ARGS
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=Release
-DFMT_DOC=OFF
-DFMT_TEST=OFF
)
ExternalProject_Get_Property(fmt source_dir)
ExternalProject_Get_Property(fmt binary_dir)
add_library(fmtlib::fmt STATIC IMPORTED)
make_directory("${source_dir}/include") # To suppress non-exist directory warnings
set_target_properties(fmtlib::fmt PROPERTIES
IMPORTED_LOCATION "${binary_dir}/libfmt.a"
INTERFACE_INCLUDE_DIRECTORIES "${source_dir}/include"
)
add_dependencies(fmtlib::fmt fmt)
ExternalProject_Add(googletest
GIT_REPOSITORY "https://github.com/google/googletest.git"
GIT_TAG "master"
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/googletest"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest/src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest/build"
STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest/stamp"
UPDATE_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
CMAKE_ARGS
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=Release
)
ExternalProject_Get_Property(googletest source_dir)
ExternalProject_Get_Property(googletest binary_dir)
add_library(googletest::gtest STATIC IMPORTED)
make_directory("${source_dir}/googletest/include") # To suppress non-exist directory warnings
set_target_properties(googletest::gtest PROPERTIES
IMPORTED_LOCATION "${binary_dir}/lib/libgtest.a"
INTERFACE_INCLUDE_DIRECTORIES "${source_dir}/googletest/include"
)
add_library(googletest::gtest_main STATIC IMPORTED)
set_target_properties(googletest::gtest_main PROPERTIES
IMPORTED_LOCATION "${binary_dir}/lib/libgtest_main.a"
)
add_dependencies(googletest::gtest googletest)
add_dependencies(googletest::gtest_main googletest)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/test")
add_executable(test_kyut
test_kyut.cpp
)
target_link_libraries(test_kyut
fmtlib::fmt
googletest::gtest
googletest::gtest_main
)
add_test(NAME tests::kyut
COMMAND $<TARGET_FILE:test_kyut>
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
#include <gtest/gtest.h>
TEST(kyut, dummy) {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment