From 58589341150ee528131479d26fb60747a4532963 Mon Sep 17 00:00:00 2001 From: Nishizaki Date: Mon, 27 May 2024 22:19:39 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B7=E3=83=B3=E3=83=97=E3=83=AB=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- c_cmake/CMakeLists.txt | 315 +----------------------- c_cmake/lib/bowling_game/CMakeLists.txt | 12 +- 2 files changed, 12 insertions(+), 315 deletions(-) diff --git a/c_cmake/CMakeLists.txt b/c_cmake/CMakeLists.txt index ad3bc1c..a227ec3 100644 --- a/c_cmake/CMakeLists.txt +++ b/c_cmake/CMakeLists.txt @@ -113,39 +113,6 @@ add_subdirectory(lib/bowling_game) ################################################################################# -include_directories(lib/bowling_game/src) - -################################################################################# - -add_executable(bowling_game_test_assert - lib/bowling_game/src/bowling_game.c - lib/bowling_game/test/assert/bowling_game_test_assert.c -) - -if(WIN32) - add_test( - NAME bowling_game_test_assert - COMMAND ${TEST_LUNCHER} bowling_game_test_assert $ - ) -elseif(UNIX) - add_test( - NAME bowling_game_test_assert - COMMAND sh ${TEST_LUNCHER} bowling_game_test_assert $ - ) -endif() - -target_include_directories(bowling_game_test_assert - PRIVATE lib/bowling_game/src -) -target_compile_options_helper(bowling_game_test_assert) - -add_custom_command( - TARGET bowling_game_test_assert POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR} -) - -################################################################################# - add_executable( bowling_game_test_pcunit lib/bowling_game/src/bowling_game.c @@ -172,291 +139,11 @@ target_include_directories(bowling_game_test_pcunit ) target_compile_options_helper(bowling_game_test_pcunit) -add_custom_command( - TARGET bowling_game_test_pcunit POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR} -) - -################################################################################# - -macro(find_test_data testfile variable) - find_file(${variable} - ${testfile} - HINTS "${CMAKE_SOURCE_DIR}/../testdata/" - REQUIRED - ) -endmacro() - -find_test_data(all_ones.txt input_file_path_all_one_test ) -find_test_data(all_zeros.txt input_file_path_all_zeros ) -find_test_data(one_spare.txt input_file_path_one_spare ) -find_test_data(one_strike.txt input_file_path_one_strike ) -find_test_data(perfect_game.txt input_file_path_perfect_game ) - ################################################################################# add_executable( bowling_game_cli - lib/bowling_game/src/bowling_game.c - src/bowling_game_cli.c -) - -macro(do_cli_test testname inputfile output) - if(WIN32) - add_test( - NAME bowling_game_cli_test_${testname} - COMMAND ${TEST_LUNCHER} bowling_game_cli_test_${testname} $ ${inputfile} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - elseif(UNIX) - add_test( - NAME bowling_game_cli_test_${testname} - COMMAND sh ${TEST_LUNCHER} bowling_game_cli_test_${testname} $ ${inputfile} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endif() - set_tests_properties( - bowling_game_cli_test_${testname} PROPERTIES - PASS_REGULAR_EXPRESSION ${output} - ) -endmacro() - -target_include_directories(bowling_game_cli - PRIVATE lib/bowling_game/src -) -target_compile_options_helper(bowling_game_cli) - -add_custom_command( - TARGET bowling_game_cli POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR} -) - -do_cli_test( - all_ones - ${input_file_path_all_one_test} - 20 -) - -do_cli_test( - all_zeros - ${input_file_path_all_zeros} - 0 -) - -do_cli_test( - one_spare - ${input_file_path_one_spare} - 16 -) - -do_cli_test( - one_strike - ${input_file_path_one_strike} - 24 -) - -do_cli_test( - perfect_game - ${input_file_path_perfect_game} - 300 -) - -do_cli_test( - no_inputfile - "" - "usage: $ inputfilename" -) - -do_cli_test( - cant_open_inputfile - cant_open_inputfile.txt - "can't open cant_open_inputfile.txt" -) - -################################################################################# - -add_executable( - bowling_game_cli_shared - src/bowling_game_cli.c -) - -target_link_libraries(bowling_game_cli_shared bowling_game_share) - -macro(do_cli_shared_test testname inputfile output) - if(WIN32) - add_test( - NAME bowling_game_cli_shared_test_${testname} - COMMAND ${TEST_LUNCHER} bowling_game_cli_shared_test_${testname} $ ${inputfile} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - elseif(UNIX) - add_test( - NAME bowling_game_cli_shared_test_${testname} - COMMAND sh ${TEST_LUNCHER} bowling_game_cli_shared_test_${testname} $ ${inputfile} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endif() - set_tests_properties( - bowling_game_cli_shared_test_${testname} PROPERTIES - PASS_REGULAR_EXPRESSION ${output} - ) -endmacro() - -target_include_directories(bowling_game_cli_shared - PRIVATE lib/bowling_game/src -) -target_compile_options_helper(bowling_game_cli_shared) - -add_custom_command( - TARGET bowling_game_cli_shared POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR} -) - -do_cli_shared_test( - all_ones - ${input_file_path_all_one_test} - 20 -) - -do_cli_shared_test( - all_zeros - ${input_file_path_all_zeros} - 0 -) - -do_cli_shared_test( - one_spare - ${input_file_path_one_spare} - 16 -) - -do_cli_shared_test( - one_strike - ${input_file_path_one_strike} - 24 -) - -do_cli_shared_test( - perfect_game - ${input_file_path_perfect_game} - 300 -) - -do_cli_shared_test( - no_inputfile - "" - "usage: $ inputfilename" -) - -do_cli_shared_test( - cant_open_inputfile - cant_open_inputfile.txt - "can't open cant_open_inputfile.txt" -) - -################################################################################# - -add_executable( - bowling_game_cli_static src/bowling_game_cli.c ) -target_link_libraries(bowling_game_cli_static bowling_game_static) - -macro(do_cli_static_test testname inputfile output) - if(WIN32) - add_test( - NAME bowling_game_cli_static_test_${testname} - COMMAND ${TEST_LUNCHER} bowling_game_cli_static_test_${testname} $ ${inputfile} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - elseif(UNIX) - add_test( - NAME bowling_game_cli_static_test_${testname} - COMMAND sh ${TEST_LUNCHER} bowling_game_cli_static_test_${testname} $ ${inputfile} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endif() - set_tests_properties( - bowling_game_cli_static_test_${testname} PROPERTIES - PASS_REGULAR_EXPRESSION ${output} - ) -endmacro() - -target_include_directories(bowling_game_cli_static - PRIVATE lib/bowling_game/src -) -target_compile_options_helper(bowling_game_cli_static) - -add_custom_command( - TARGET bowling_game_cli_static POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_BINARY_DIR} -) - -do_cli_static_test( - all_ones - ${input_file_path_all_one_test} - 20 -) - -do_cli_static_test( - all_zeros - ${input_file_path_all_zeros} - 0 -) - -do_cli_static_test( - one_spare - ${input_file_path_one_spare} - 16 -) - -do_cli_static_test( - one_strike - ${input_file_path_one_strike} - 24 -) - -do_cli_static_test( - perfect_game - ${input_file_path_perfect_game} - 300 -) - -do_cli_static_test( - no_inputfile - "" - "usage: $ inputfilename" -) - -do_cli_static_test( - cant_open_inputfile - cant_open_inputfile.txt - "can't open cant_open_inputfile.txt" -) - -################################################################################# - -if(WIN32) - -file(WRITE ${CMAKE_BINARY_DIR}/config.bat "@echo off -cd /D %~dp0 -cmake . %* -cmd /K -") - -file(WRITE ${CMAKE_BINARY_DIR}/config-gui.bat "cd /D %~dp0 -start cmake-gui . %* -") - -file(WRITE ${CMAKE_BINARY_DIR}/ninja_-t_deps.bat "cd /D %~dp0 -ninja -t deps %* -") - -# ビルドとテストを実行するバッチ -configure_file(../utility/build_and_test.bat.in build_and_test.bat) - -elseif(UNIX) - -endif() +target_link_libraries(bowling_game_cli bowling_game_static) diff --git a/c_cmake/lib/bowling_game/CMakeLists.txt b/c_cmake/lib/bowling_game/CMakeLists.txt index 302a92d..52040d6 100644 --- a/c_cmake/lib/bowling_game/CMakeLists.txt +++ b/c_cmake/lib/bowling_game/CMakeLists.txt @@ -37,6 +37,12 @@ add_library( src/bowling_game.c ) +target_include_directories( + bowling_game_share + PUBLIC + src +) + ################################################################################# add_library( @@ -45,4 +51,8 @@ add_library( src/bowling_game.c ) -################################################################################# +target_include_directories( + bowling_game_static + PUBLIC + src +)