Skip to content

Commit a20573f

Browse files
authored
Use cmake subdir for test (#13)
* Use CMake subdirectory for test Use CMake's subdirectory support for tests. Remove redundant CMake lines in the parent and subdirectory. * Remove unneeded call to make test Now with the subdirectory structure one "make test" works.
1 parent b8313b9 commit a20573f

File tree

3 files changed

+2
-45
lines changed

3 files changed

+2
-45
lines changed

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,4 @@ install(TARGETS cpptcl_static ARCHIVE DESTINATION lib)
6464
install(FILES ${HDRS} DESTINATION include/cpptcl)
6565
install(FILES ${HDRS_DETAILS} DESTINATION include/cpptcl/details)
6666

67-
add_executable(cpptcl_test test/test_main.cc)
68-
add_test(test1 cpptcl_test)
69-
target_link_libraries(cpptcl_test PUBLIC cpptcl ${TCL_LIBRARY} ${TCL_STUB_LIBRARY})
67+
add_subdirectory(test)

COMMONmakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ install: all
1818

1919
test: all
2020
(cd build; make test)
21-
(cd test; make test)
2221

2322
MODULE_SRCS = modules/example_functions/cpptcl_example_functions.cc
2423

test/CMakeLists.txt

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,5 @@
11
cmake_minimum_required(VERSION 3.0)
22

3-
if (NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
4-
set(CMAKE_CXX_COMPILER clang++)
5-
endif()
6-
7-
project(cpptcl_test)
8-
9-
set(TCLSH_VERSION_STRING, "8.6")
10-
11-
set(CMAKE_CXX_STANDARD 14)
12-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
13-
set(CMAKE_CXX_EXTENSIONS OFF)
14-
15-
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
16-
list(APPEND OPTS -stdlib=libc++)
17-
list(APPEND OPTS -Wno-reserved-id-macro)
18-
list(APPEND OPTS -Wno-padded)
19-
list(APPEND OPTS -Wno-c++98-compat)
20-
endif()
21-
22-
include (CTest)
23-
24-
find_path(TCL_INCLUDE_PATH tcl.h PATHS /usr/local/include/tcl8.6 /usr/include/tcl8.6 NO_DEFAULT_PATH)
25-
find_library(TCL_LIBRARY NAMES tcl8.6 tcl86 PATHS /usr/local/lib /usr/lib)
26-
find_library(TCL_STUB_LIBRARY NAMES tclstub8.6 tclstub86 PATHS /usr/local/lib /usr/lib)
27-
28-
message(INFO " Tcl include ${TCL_INCLUDE_PATH}")
29-
message(INFO " Tcl library ${TCL_LIBRARY}")
30-
message(INFO " Tcl stub library ${TCL_STUB_LIBRARY}")
31-
32-
if(NOT TCL_LIBRARY)
33-
message(FATAL_ERROR " Tcl library not found")
34-
endif()
35-
36-
#set(CMAKE_BUILD_TYPE Debug)
37-
set(CMAKE_BUILD_TYPE Release)
38-
39-
include_directories(${CMAKE_SOURCE_DIR}/.. ${TCL_INCLUDE_PATH})
40-
41-
add_compile_options(${OPTS})
42-
433
add_executable(test1 test1.cc ../cpptcl.cc)
444
add_test(test1 test1)
455
target_link_libraries(test1 PUBLIC ${TCL_LIBRARY} ${TCL_STUB_LIBRARY})
@@ -71,5 +31,5 @@ target_link_libraries(test_main PUBLIC ${TCL_LIBRARY} ${TCL_STUB_LIBRARY})
7131
set(TCL_TCLSH tclsh8.6)
7232
add_library(test2 SHARED test2.cc ../cpptcl.cc)
7333
target_link_libraries(test2 PUBLIC ${TCL_LIBRARY} ${TCL_STUB_LIBRARY})
74-
add_test(NAME test2 COMMAND ${TCL_TCLSH} ../test2.tcl)
34+
add_test(NAME test2 COMMAND ${TCL_TCLSH} ${CMAKE_SOURCE_DIR}/test/test2.tcl)
7535

0 commit comments

Comments
 (0)