Skip to content

Commit 2af5ed7

Browse files
sobucherhankur
authored andcommitted
cmake: fix cmake build without internal jimtcl
1 parent 06b7494 commit 2af5ed7

File tree

8 files changed

+31
-6
lines changed

8 files changed

+31
-6
lines changed

.gitlab/ci/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
wget https://dl.espressif.com/dl/$JIMTCL_VER.tar.gz -O $JIMTCL_VER.tar.gz
8686
tar xzf $JIMTCL_VER.tar.gz && rm $JIMTCL_VER.tar.gz
8787
pushd $JIMTCL_VER
88-
./configure --prefix="$PWD/dist" --host=${CONF_HOST} --disable-shared CC=${HOST_CC}
88+
./configure --prefix="$PWD/dist" --host=${CONF_HOST} --disable-shared --with-ext=json --minimal --disable-ssl CC=${HOST_CC}
8989
make
9090
# Running "make" does not create this file for static builds on Windows but "make install" still expects it
9191
touch build-jim-ext

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ include(cmake/configure.cmake)
88

99
add_executable(openocd)
1010

11-
include(cmake/jimtcl.cmake)
11+
if(use_internal_jimtcl)
12+
include(cmake/jimtcl.cmake)
13+
elseif(JIMTCL_FOUND)
14+
add_library(libjimtcl INTERFACE)
15+
target_include_directories(libjimtcl INTERFACE ${JIMTCL_INCLUDE_DIRS})
16+
target_link_libraries(libjimtcl INTERFACE ${JIMTCL_LINK_LIBRARIES})
17+
elseif(have_jim_h)
18+
add_library(libjimtcl INTERFACE)
19+
target_link_libraries(libjimtcl INTERFACE jim)
20+
endif()
21+
1222
add_subdirectory(src)
1323

1424
# Propogate config.h which is auto-generated into the root directory.

cmake/BuildOptions.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ option(VERBOSE_JTAG_IO "Verbose JTAG I/O messages (for debugging)" OFF)
99
option(VERBOSE_USB_IO "Verbose USB I/O messages (for debugging)" OFF)
1010
option(VERBOSE_USB_COMM "Verbose USB communication messages (for debugging)" OFF)
1111
option(MALLOC_LOGGING "Include free space in logging messages (requires malloc.h)" OFF)
12-
option(BUILD_DUMMY "Build the dummy port driver" OFF)
12+
option(BUILD_DUMMY "Build the dummy port driver" ON)
1313
option(BUILD_RSHIM "Build the rshim driver" OFF)
1414
option(BUILD_DMEM "Build the dmem driver" OFF)
1515
option(BUILD_PARPORT "Build the pc parallel port driver" OFF)
@@ -26,8 +26,9 @@ option(BUILD_EP93XX "Build support for EP93xx based SBCs" OFF)
2626
option(BUILD_AT91RM9200 "Build support for AT91RM9200 based SBCs" OFF)
2727
option(BUILD_GW16012 "Build support for the Gateworks GW16012 JTAG Programmer" OFF)
2828
option(BUILD_SYSFSGPIO "Build support for programming driven via sysfs gpios" OFF)
29+
option(BUILD_LINUXSPIDEV "Build support for Linux SPI device SWD adapter" OFF)
2930
option(BUILD_XLNX_PCIE_XVC "Build support for Xilinx XVC/PCIe" OFF)
30-
option(use_internal_jimtcl "Build internal jimtcl" ON)
31+
option(use_internal_jimtcl "Build internal jimtcl" OFF)
3132
option(use_internal_jimtcl_maintainer "Maintainer mode when building internal jimtcl" OFF)
3233
option(use_internal_libjaylink "Build internal libjaylink" OFF)
3334
option(BUILD_REMOTE_BITBANG "Build support for the Remote Bitbang driver" ON)

cmake/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
/* 0 if you don't want SysfsGPIO driver */
8080
#cmakedefine01 BUILD_SYSFSGPIO
8181

82+
/* 0 if you don't want Linux SPI SWD adapter driver */
83+
#cmakedefine01 BUILD_LINUXSPIDEV
84+
8285
/* 0 if you don't want Xilinx XVC/PCIe driver */
8386
#cmakedefine01 BUILD_XLNX_PCIE_XVC
8487

cmake/configure.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ if(ENABLE_CAPSTONE)
141141
endif()
142142
endif()
143143

144+
pkg_check_modules(JIMTCL jimtcl>=0.79)
145+
if(NOT JIMTCL_FOUND AND NOT use_internal_jimtcl)
146+
check_include_file(jim.h have_jim_h)
147+
if(NOT have_jim_h)
148+
message(FATAL_ERROR "Jim TCL package not found\n"
149+
"Either configure to build version from submodule using 'cmake -D use_internal_jimtcl=ON', "
150+
"or provide path to search for package configuration files in environment variable"
151+
"'PKG_CONFIG_PATH' / 'OSXCROSS_PKG_CONFIG_PATH'")
152+
endif()
153+
endif()
144154

145155
# Process options
146156
if(doxygen_as_html)

cmake/jimtcl.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include(ExternalProject)
33
set(JIMTCL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jimtcl)
44
set(JIMTCL_BIN ${CMAKE_CURRENT_BINARY_DIR}/jimtcl)
55
set(JIMTCL_STATIC_LIB ${JIMTCL_DIR}/libjim.a)
6-
set(JIMTCL_INCLUDES ${JIMTCL_BIN})
6+
set(JIMTCL_INCLUDES ${JIMTCL_DIR})
77

88
if(${CMAKE_CROSSCOMPILING})
99
set(CONF_HOST --host=${host})

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ list(APPEND openocd_targets
5959

6060
foreach(target ${openocd_targets})
6161
target_compile_options(${target} PUBLIC ${OPENOCD_COMMON_COMPILER_FLAGS})
62-
target_include_directories(${target} PUBLIC ${JIMTCL_DIR})
62+
target_include_directories(${target} BEFORE PUBLIC $<TARGET_PROPERTY:libjimtcl,INTERFACE_INCLUDE_DIRECTORIES>)
6363
target_include_directories(${target} BEFORE PUBLIC $<TARGET_PROPERTY:openocd,INTERFACE_INCLUDE_DIRECTORIES>)
6464
target_include_directories(${target} BEFORE PUBLIC $<TARGET_PROPERTY:openocd_main,INTERFACE_INCLUDE_DIRECTORIES>)
6565
endforeach()

src/flash/nor/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ target_sources(nor PRIVATE
2222
cc26xx.c
2323
cfi.c
2424
dsp5680xx_flash.c
25+
dw-spi.c
2526
efm32.c
2627
em357.c
2728
eneispif.c

0 commit comments

Comments
 (0)