Skip to content

Commit

Permalink
使用新的组织结构
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Oct 1, 2017
1 parent 15d761e commit 0915781
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 75 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cmake_minimum_required(VERSION 3.7.0)

enable_testing()

project(libcopp)

########################################################################
Expand Down
36 changes: 4 additions & 32 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,39 +197,11 @@ test_script:
} else {
& "bin/$Env:CONFIGURATION/libcopp_unit_test.exe"
& cmake --build . --config $Env:CONFIGURATION --target run_sample
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_coroutine_mem_pool.exe" 40000 1000 64
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_coroutine_mem_pool.exe" 1000 1000 2048
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_coroutine.exe" 40000 1000 64
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_coroutine.exe" 1000 1000 2048
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_coroutine_malloc.exe" 40000 1000 64
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_coroutine_malloc.exe" 1000 1000 2048
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_coroutine_stack_pool.exe" 40000 1000 64
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_coroutine_stack_pool.exe" 1000 1000 2048
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_task_mem_pool.exe" 40000 1000 64
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_task_mem_pool.exe" 1000 1000 2048
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_task.exe" 40000 1000 64
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_task.exe" 1000 1000 2048
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_task_malloc.exe" 40000 1000 64
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_task_malloc.exe" 1000 1000 2048
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_task_stack_pool.exe" 40000 1000 64
& "bin/$Env:CONFIGURATION/libcopp_sample_benchmark_task_stack_pool.exe" 1000 1000 2048
& cmake --build . --config $Env:CONFIGURATION --target run_test
& cmake --build . --config $Env:CONFIGURATION --target benchmark
}
Expand Down
14 changes: 4 additions & 10 deletions project/cmake/TargetOption.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# 设置实际的默认编译输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")

set(PROJECT_TARGET_INSTALL_EXECUTABLE_DIR "bin")
set(PROJECT_TARGET_INSTALL_ARCHIVE_DIR "lib")
set(PROJECT_TARGET_INSTALL_LIBRARY_DIR "lib")

if (WIN32)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(PROJECT_TARGET_INSTALL_LIBRARY_DIR "bin")
link_directories (${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
else ()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(PROJECT_TARGET_INSTALL_LIBRARY_DIR "lib")
endif ()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")
# set(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin")

link_directories (${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
54 changes: 29 additions & 25 deletions sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ file(GLOB SAMPLE_SRC_LIST RELATIVE "${PROJECT_SAMPLE_SRC_DIR}"
${PROJECT_SAMPLE_SRC_DIR}/*.cxx
)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/sample")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

foreach(SAMPLE_SRC_FILE IN LISTS SAMPLE_SRC_LIST)
get_filename_component(SAMPLE_SRC_BIN_NAME ${SAMPLE_SRC_FILE} NAME_WE)
set(SAMPLE_SRC_BIN_NAME "libcopp_${SAMPLE_SRC_BIN_NAME}")
Expand All @@ -22,30 +28,28 @@ foreach(SAMPLE_SRC_FILE IN LISTS SAMPLE_SRC_LIST)
${COMPILER_OPTION_EXTERN_CXX_LIBS}
)

if(NOT MSVC)
# add benchmark script
string(FIND ${SAMPLE_SRC_BIN_NAME} "_benchmark_" SAMPLE_SRC_IS_BENCHMARK)

add_custom_target("run_test_${SAMPLE_SRC_BIN_NAME}_40000"
"./${SAMPLE_SRC_BIN_NAME}" 40000 1000 64
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
if (${SAMPLE_SRC_IS_BENCHMARK} LESS 0)
add_dependencies(run_sample "run_test_${SAMPLE_SRC_BIN_NAME}_40000")
else()
add_dependencies(benchmark "run_test_${SAMPLE_SRC_BIN_NAME}_40000")
endif()
add_dependencies("run_test_${SAMPLE_SRC_BIN_NAME}_40000" ${SAMPLE_SRC_BIN_NAME})

add_custom_target("run_test_${SAMPLE_SRC_BIN_NAME}_1000"
"./${SAMPLE_SRC_BIN_NAME}" 1000 1000 2048
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
if (${SAMPLE_SRC_IS_BENCHMARK} LESS 0)
add_dependencies(run_sample "run_test_${SAMPLE_SRC_BIN_NAME}_1000")
else ()
add_dependencies(benchmark "run_test_${SAMPLE_SRC_BIN_NAME}_1000")
endif()
add_dependencies("run_test_${SAMPLE_SRC_BIN_NAME}_1000" ${SAMPLE_SRC_BIN_NAME})
# add benchmark script
string(FIND ${SAMPLE_SRC_BIN_NAME} "_benchmark_" SAMPLE_SRC_IS_BENCHMARK)

add_custom_target("run_test_${SAMPLE_SRC_BIN_NAME}_40000"
"./${SAMPLE_SRC_BIN_NAME}${CMAKE_EXECUTABLE_SUFFIX}" 40000 1000 64
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
if (${SAMPLE_SRC_IS_BENCHMARK} LESS 0)
add_dependencies(run_sample "run_test_${SAMPLE_SRC_BIN_NAME}_40000")
else()
add_dependencies(benchmark "run_test_${SAMPLE_SRC_BIN_NAME}_40000")
endif()
add_dependencies("run_test_${SAMPLE_SRC_BIN_NAME}_40000" ${SAMPLE_SRC_BIN_NAME})

add_custom_target("run_test_${SAMPLE_SRC_BIN_NAME}_1000"
"./${SAMPLE_SRC_BIN_NAME}${CMAKE_EXECUTABLE_SUFFIX}" 1000 1000 2048
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
if (${SAMPLE_SRC_IS_BENCHMARK} LESS 0)
add_dependencies(run_sample "run_test_${SAMPLE_SRC_BIN_NAME}_1000")
else ()
add_dependencies(benchmark "run_test_${SAMPLE_SRC_BIN_NAME}_1000")
endif()
add_dependencies("run_test_${SAMPLE_SRC_BIN_NAME}_1000" ${SAMPLE_SRC_BIN_NAME})
endforeach()
19 changes: 11 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ if ( NOT MSVC )
endif()

# ============ test - coroutine test frame ============
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/test")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

add_executable(libcopp_unit_test ${COPP_TEST_SRC_LIST})
target_link_libraries(libcopp_unit_test
Expand All @@ -71,11 +76,9 @@ target_link_libraries(libcopp_unit_test
${COMPILER_OPTION_EXTERN_CXX_LIBS}
)

if(NOT MSVC)
add_custom_target(run_test_libcopp_unit_test
./libcopp_unit_test
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
)
add_dependencies(run_test run_test_libcopp_unit_test)
add_dependencies(run_test_libcopp_unit_test libcopp_unit_test)
endif()
add_custom_target(run_test_libcopp_unit_test
"./libcopp_unit_test${CMAKE_EXECUTABLE_SUFFIX}"
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
add_dependencies(run_test run_test_libcopp_unit_test)
add_dependencies(run_test_libcopp_unit_test libcopp_unit_test)

0 comments on commit 0915781

Please sign in to comment.