Create bat for test exe
This commit is contained in:
parent
9cf58f6e70
commit
f766f2df22
8
Makefile
8
Makefile
|
@ -68,10 +68,18 @@ build: third_party
|
||||||
test: install
|
test: install
|
||||||
@$(call echo,Make $@)
|
@$(call echo,Make $@)
|
||||||
@$(call echo,Make gtest,33)
|
@$(call echo,Make gtest,33)
|
||||||
|
ifeq ($(HOST_OS),Win)
|
||||||
|
@$(call cmake_build,./test/gtest/_build,..,-Dgtest_force_shared_crt=ON)
|
||||||
|
else
|
||||||
@$(call cmake_build,./test/gtest/_build)
|
@$(call cmake_build,./test/gtest/_build)
|
||||||
|
endif
|
||||||
@$(call echo,Make test,33)
|
@$(call echo,Make test,33)
|
||||||
@$(call cmake_build,./test/_build)
|
@$(call cmake_build,./test/_build)
|
||||||
|
ifeq ($(HOST_OS),Win)
|
||||||
|
@.\\\test\\\_output\\\bin\\\mynteye_test.bat
|
||||||
|
else
|
||||||
@./test/_output/bin/mynteye_test
|
@./test/_output/bin/mynteye_test
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
include(CMakeParseArguments)
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
|
set(CUR_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
if(MSVC OR MSYS OR MINGW)
|
if(MSVC OR MSYS OR MINGW)
|
||||||
set(OS_WIN TRUE)
|
set(OS_WIN TRUE)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
@ -24,3 +26,42 @@ macro(set_outdir ARCHIVE_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY RUNTIME_OUTPU
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
macro(exe2bat exe_name exe_dir dll_search_paths)
|
||||||
|
message(STATUS "Generating ${exe_name}.bat")
|
||||||
|
set(__exe_name ${exe_name})
|
||||||
|
set(__dll_relative_search_paths "")
|
||||||
|
foreach(path ${dll_search_paths})
|
||||||
|
file(RELATIVE_PATH __relative_path "${exe_dir}" "${path}")
|
||||||
|
file(TO_NATIVE_PATH ${__relative_path} __relative_path)
|
||||||
|
list(APPEND __dll_relative_search_paths ${__relative_path})
|
||||||
|
endforeach()
|
||||||
|
#message(STATUS __dll_relative_search_paths: "${__dll_relative_search_paths}")
|
||||||
|
set(__dll_search_paths "${__dll_relative_search_paths}")
|
||||||
|
configure_file(
|
||||||
|
"${CUR_DIR}/templates/exe.bat.in"
|
||||||
|
"${exe_dir}/${__exe_name}.bat"
|
||||||
|
)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# target_create_scripts(NAME
|
||||||
|
# [BIN_DIR bin_dir]
|
||||||
|
# [DLL_SEARCH_PATHS path1 path2 ...])
|
||||||
|
macro(target_create_scripts NAME)
|
||||||
|
set(options BIN_DIR)
|
||||||
|
set(oneValueArgs)
|
||||||
|
set(multiValueArgs DLL_SEARCH_PATHS)
|
||||||
|
cmake_parse_arguments(THIS "${options}" "${oneValueArgs}"
|
||||||
|
"${multiValueArgs}" ${ARGN})
|
||||||
|
if(NOT THIS_BIN_DIR)
|
||||||
|
set(THIS_BIN_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#message(STATUS "NAME: ${NAME}")
|
||||||
|
#message(STATUS "THIS_BIN_DIR: ${THIS_BIN_DIR}")
|
||||||
|
#message(STATUS "THIS_DLL_SEARCH_PATHS: ${THIS_DLL_SEARCH_PATHS}")
|
||||||
|
|
||||||
|
if(OS_WIN)
|
||||||
|
exe2bat("${NAME}" "${THIS_BIN_DIR}" "${THIS_DLL_SEARCH_PATHS}")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
13
cmake/templates/exe.bat.in
Normal file
13
cmake/templates/exe.bat.in
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
@echo off
|
||||||
|
set "MY_DIR=%~dp0"
|
||||||
|
set "MY_PWD=%cd%"
|
||||||
|
|
||||||
|
if "%MY_PATH_SET_@__exe_name@%"=="" (
|
||||||
|
set "MY_PATH_SET_@__exe_name@=1"
|
||||||
|
set "PATH=@__dll_search_paths@;%PATH%"
|
||||||
|
)
|
||||||
|
|
||||||
|
cd "%MY_DIR%"
|
||||||
|
"%MY_DIR%@__exe_name@.exe" %*
|
||||||
|
cd "%MY_PWD%"
|
||||||
|
::pause >nul
|
|
@ -21,6 +21,20 @@ include(${PRO_DIR}/cmake/DetectCXX11.cmake)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
||||||
|
|
||||||
|
#if(OS_WIN AND NOT MINGW)
|
||||||
|
# set(CompilerFlags
|
||||||
|
# CMAKE_CXX_FLAGS
|
||||||
|
# CMAKE_CXX_FLAGS_DEBUG
|
||||||
|
# CMAKE_CXX_FLAGS_RELEASE
|
||||||
|
# CMAKE_C_FLAGS
|
||||||
|
# CMAKE_C_FLAGS_DEBUG
|
||||||
|
# CMAKE_C_FLAGS_RELEASE
|
||||||
|
# )
|
||||||
|
# foreach(CompilerFlag ${CompilerFlags})
|
||||||
|
# string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
||||||
|
# endforeach()
|
||||||
|
#endif()
|
||||||
|
|
||||||
string(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
|
string(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
|
||||||
string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
|
string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
|
||||||
message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS}")
|
message(STATUS "C_FLAGS: ${CMAKE_C_FLAGS}")
|
||||||
|
@ -80,6 +94,9 @@ add_executable(${PROJECT_NAME}
|
||||||
${TEST_PUBLIC_SRC}
|
${TEST_PUBLIC_SRC}
|
||||||
)
|
)
|
||||||
target_link_libraries(${PROJECT_NAME} ${GTEST_LIBS} mynteye)
|
target_link_libraries(${PROJECT_NAME} ${GTEST_LIBS} mynteye)
|
||||||
|
target_create_scripts(${PROJECT_NAME} DLL_SEARCH_PATHS
|
||||||
|
${PRO_DIR}/_install/bin
|
||||||
|
)
|
||||||
|
|
||||||
if(OS_WIN)
|
if(OS_WIN)
|
||||||
target_compile_definitions(${PROJECT_NAME}
|
target_compile_definitions(${PROJECT_NAME}
|
||||||
|
|
|
@ -1,31 +1,10 @@
|
||||||
#include "gtest/gtest.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "glog/logging.h"
|
|
||||||
|
|
||||||
struct glog_init {
|
#include "gtest/gtest.h"
|
||||||
glog_init(int /*argc*/, char *argv[]) {
|
|
||||||
// FLAGS_logtostderr = true;
|
|
||||||
FLAGS_alsologtostderr = true;
|
|
||||||
FLAGS_colorlogtostderr = true;
|
|
||||||
|
|
||||||
FLAGS_log_dir = ".";
|
#include "mynteye/glog_init.h"
|
||||||
FLAGS_max_log_size = 1024;
|
|
||||||
FLAGS_stop_logging_if_full_disk = true;
|
|
||||||
|
|
||||||
// FLAGS_v = 2;
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
|
|
||||||
VLOG(2) << __func__;
|
|
||||||
}
|
|
||||||
|
|
||||||
~glog_init() {
|
|
||||||
VLOG(2) << __func__;
|
|
||||||
google::ShutdownGoogleLogging();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GTEST_API_ int main(int argc, char **argv) {
|
|
||||||
glog_init _(argc, argv);
|
glog_init _(argc, argv);
|
||||||
|
|
||||||
printf("Running main() from gtest_main.cc\n");
|
printf("Running main() from gtest_main.cc\n");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user