macro not defined (__ARCH_NAME): build a cmake project with green hill multi on windows

my CMakeLists.txt:
project(myhello)

add_executable(hello_test hello.c)

=================================================================
on cmd:
C:\Users\tianfang\Desktop\tianfang\src\hello>cmake -G “Green Hills MULTI” -T c:\ghs\comp_202214 -D GHS_OS_DIR=c:\ghs\int19015 -D GHS_BSP_NAME=platform-zynq-mp -D GHS_PRIMARY_TARGET=arm64_integrity.tgt -D GHS__BSP_NAME=platform-zynq-mp -D GHS__ARCH_NAME=arm64 -S . -B c:\build\hello
– The C compiler identification is GHS 2022.1.4
– The CXX compiler identification is GHS 2022.1.4
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: C:/ghs/comp_202214/ccintarm64.exe - skipped
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: C:/ghs/comp_202214/cxintarm64.exe - skipped
– Configuring done
– Generating done
CMake Warning:
Manually-specified variables were not used by the project:

GHS__ARCH_NAME
GHS__BSP_NAME

– Build files have been written to: C:/build/hello

Then exe gbuild:

c:\build\hello>gbuild -top myhello.top.gpj
macro not defined(__ARCH_NAME) …
macro not defined(__ARCH_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__ARCH_NAME) …
macro not defined(__ARCH_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__BSP_NAME) …
macro not defined(__ARCH_NAME) …
Building C:\build\hello\myhello.top.gpj
Compiling hello.c because hello.o does not exist
Output from Compiling hello.c:
“C:\Users\tianfang\Desktop\tianfang\src\hello\hello.c”, line 4: warning #951-D:
return type of function “main” must be “int”
void main()
^

Linking hello_test because it does not exist
Output from Linking hello_test.gpj:
ccintarm64: Warning: Cannot open library libinit.a
ccintarm64: Warning: Cannot open library libutil.a
ccintarm64: Warning: Cannot open library libINTEGRITY.a
[elxr] (error #21) cannot find library -linit
Error: build failed

c:\build\hello>

I’m new for multi ide on windows, I also look for info in multi manul, but failed to build them. any suggestions?

The problem of “macro not defined” can be resolved by modifying C:\build\hello\myhello.top.gpj

Insert :
macro __ARCH_NAME=arm64
macro __BSP_NAME=platform-zynq-mp

However, how to resolve macro issue without modification of myhello.top.gpj and how to resolve library linking ?

Thanks

Never used the GHS generator, but according to the manual you need to specify the architecture with -A and there are no variables with two underscores as in your example.

Specifying the primary target should also be not necessary, as it seems to be the default. And for whatever reason the manual says to use CMake style path for -T.
So something like this should work:

cmake -G “Green Hills MULTI” -T c:/ghs/comp_202214 -D GHS_OS_DIR=c:/ghs/int19015 -D GHS_BSP_NAME=platform-zynq-mp -A arm64 -S . -B c:\build\hello

thanks for your reply Josef.

I feel confused:
when I do a configure of source c/c++ code via cmake on windows, how does cmake tool search include files ?

here are details:

toolchain.cmake:

set(CMAKE_CROSSCOMPILING TRUE)

set ( GHS_BSP_NAME "platform-zynq-mp" )
set ( __ARCH_NAME arm64 )
set ( __BSP_CFG_NAME dbg )
set ( GHS_OS_DIR c:/ghs/int19015 )
set ( CMAKE_FIND_ROOT_PATH   "  C:/ghs   C:/ghs/int19015/asp/arm64/INTEGRITY-include     
C:/ghs/int19015/platform-zynq-mp  
C:ghs/int19015/INTEGRITY-include       
C:/ghs/int19015/intlib    
C:/ghs/int19015     
c:/ghs/int19015/kernel       
c:/ghs/int19015/bin/platform-zynq-mp/dbg     
c:/ghs/int19015/target/libs/arm64     
c:/ghs/comp_202214/**ansi**      
c:/ghs/comp_202214     
C:/Users/tianfang/Desktop/tianfang/src/glog035/glog-0.3.5      
C:/build/glog" )

set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

I can find inttypes.h in this dir: C:\ghs\comp_202214\ansi\inttypes.h, but cmake can’t find inttypes.h

cmdline:

C:\Users\tianfang\Desktop\tianfang\src\glog035\glog-0.3.5>     cmake -G "Green Hills MULTI" -T c:\ghs\comp_202214 -D GHS_OS_DIR=c:\ghs\int19015 -D GHS_BSP_NAME=platform-zynq-mp     -D BUILD_SHARED_LIBS=ON  -S . -B c:\build\glog -A arm64 --fresh  --toolchain C:\ghs\toolchain.cmake

log:

-- The C compiler identification is GHS 2022.1.4
-- The CXX compiler identification is GHS 2022.1.4
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/ghs/comp_202214/ccintarm64.exe - skipped
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/ghs/comp_202214/cxintarm64.exe - skipped
CMake Warning at CMakeLists.txt:52 (find_package):
  By not providing "Findgflags.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "gflags", but
  CMake did not find one.

  Could not find a package configuration file provided by "gflags" with any
  of the following names:

    gflagsConfig.cmake
    gflags-config.cmake

  Add the installation prefix of "gflags" to CMAKE_PREFIX_PATH or set
  "gflags_DIR" to a directory containing one of the above files.  If "gflags"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Looking for dlfcn.h
-- Looking for dlfcn.h - not found
-- Looking for execinfo.h
-- Looking for execinfo.h - not found
-- Looking for glob.h
-- Looking for glob.h - not found
-- Looking for inttypes.h
-- Looking for inttypes.h - not found
-- Looking for libunwind.h
-- Looking for libunwind.h - not found
-- Looking for memory.h
-- Looking for memory.h - not found
-- Looking for pwd.h
-- Looking for pwd.h - not found
-- Looking for stdint.h

Could you please give some suggestions? How does cmake(check_include_file function) search include path on windows?
@fdk17

You might be interested in the --debug-find flag to debug find_* commands.

This seems to be missing a / after the C: here.

When you assign to CMAKE_FIND_ROOT_PATH, it expects a list, but you’ve provided a single quoted string with space-separated values. Remove the quotes from your set(CMAKE_FIND_ROOT_PATH ...) call. Also note that wildcards are not supported, so c:/ghs/comp_202214/**ansi** is unlikely to do what you are probably expecting it to.

hi Ben,

thank you for your help. After fix it (C:/ghs/int19015/INTEGRITY-include), it deson’t work

I will look into --debug-find flag.

hi Craig,

thanks for your help.

After I fix it, it doesn’t work:

set(CMAKE_CROSSCOMPILING TRUE)

set ( GHS_BSP_NAME “platform-zynq-mp” )
set ( __ARCH_NAME arm64 )
set ( __BSP_CFG_NAME dbg )
set ( GHS_OS_DIR c:/ghs/int19015 )

set ( CMAKE_FIND_ROOT_PATH
c:/ghs
C:/ghs/int19015/asp/arm64/INTEGRITY-include
C:/ghs/int19015/platform-zynq-mp
C:/ghs/int19015/INTEGRITY-include
C:/ghs/int19015/intlib
C:/ghs/int19015
c:/ghs/int19015/kernel
c:/ghs/int19015/bin/platform-zynq-mp/dbg
c:/ghs/int19015/target/libs/arm64
c:/ghs/comp_202214/ansi
c:/ghs/comp_202214
)

set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

=============================================================
cmadline:

C:\ghs\src\glog-master>cmake -G “Green Hills MULTI” -A arm64 -T c:\ghs\comp_202214 -D GHS_OS_DIR=c:\ghs\int19015 -D GHS_BSP_NAME=platform-zynq-mp -D BUILD_SHARED_LIBS=ON -S . -B c:\ghs\build\glogtest --fresh --toolchain C:\ghs\toolchain.cmake
– The CXX compiler identification is GHS 2022.1.4
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: C:/ghs/comp_202214/cxintarm64.exe - skipped
– Could NOT find GTest (missing: GTest_DIR)
CMake Warning at CMakeLists.txt:82 (find_package):
By not providing “Findgflags.cmake” in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by “gflags”, but
CMake did not find one.

Could not find a package configuration file provided by “gflags” (requested
version 2.2.2) with any of the following names:

gflagsConfig.cmake
gflags-config.cmake

Add the installation prefix of “gflags” to CMAKE_PREFIX_PATH or set
“gflags_DIR” to a directory containing one of the above files. If “gflags”
provides a separate development package or SDK, be sure it has been
installed.

– Performing Test CMAKE_HAVE_LIBC_PTHREAD
– Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
– Looking for pthread_create in posix
– Looking for pthread_create in posix - not found
– Looking for pthread_create in pthread
– Looking for pthread_create in pthread - not found
– Check if compiler accepts -pthread
– Check if compiler accepts -pthread - no
– Could NOT find Threads (missing: Threads_FOUND)
– Could NOT find Unwind (missing: Unwind_INCLUDE_DIR Unwind_LIBRARY)
– Looking for _Unwind_Backtrace
– Looking for _Unwind_Backtrace - not found
– Looking for _Unwind_GetIP
– Looking for _Unwind_GetIP - not found
– Looking for C++ include dlfcn.h
– Looking for C++ include dlfcn.h - not found
– Looking for C++ include glob.h
– Looking for C++ include glob.h - not found
– Looking for C++ include inttypes.h
– Looking for C++ include inttypes.h - not found
– Looking for C++ include memory.h
– Looking for C++ include memory.h - not found
– Looking for C++ include pwd.h
– Looking for C++ include pwd.h - not found
– Looking for C++ include stdint.h

hi Ben,

I have tried debug, the details are shown:

  1. cmd line:
    cmake -G “Green Hills MULTI” -A arm64 -T c:\ghs\comp_202214 -D GHS_OS_DIR=c:\ghs\int19015 -D GHS_BSP_NAME=platform-zynq-mp -D BUILD_SHARED_LIBS=ON -S . -B c:\ghs\build\glogtest --fresh --toolchain C:\ghs\toolchain.cmake

  2. toolchain.cmake:
    set(CMAKE_CROSSCOMPILING TRUE)
    set ( GHS_BSP_NAME “platform-zynq-mp” )
    set ( __ARCH_NAME arm64 )
    set ( __BSP_CFG_NAME dbg )
    set ( GHS_OS_DIR c:/ghs/int19015 )

for test: inttypes.h is located in c:/ghs/comp_202214/ansi/ dir as default#

set ( CMAKE_FIND_ROOT_PATH c:/ghs/comp_202214/ansi c:/ghs/comp_202214 )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

  1. CMakeLists.txt of glog source:
    set(CMAKE_FIND_DEBUG_MODE TRUE)
    check_include_file_cxx (inttypes.h HAVE_INTTYPES_H)
    find_file(MTF inttypes.h)
    set(CMAKE_FIND_DEBUG_MODE FALSE)

  2. log of cmake config:
    – Looking for C++ include inttypes.h
    – Looking for C++ include inttypes.h - not found
    CMake Debug Log at CMakeLists.txt:108 (find_file):
    find_file called with the following settings:

    VAR: MTF
    NAMES: “inttypes.h”
    Documentation: Path to a file.
    Framework
    Only Search Frameworks: 0
    Search Frameworks Last: 0
    Search Frameworks First: 0
    AppBundle
    Only Search AppBundle: 0
    Search AppBundle Last: 0
    Search AppBundle First: 0
    CMAKE_FIND_USE_CMAKE_PATH: 1
    CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
    CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
    CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
    CMAKE_FIND_USE_INSTALL_PREFIX: 1

find_file considered the following locations:

c:/ghs/comp_202214/ansi/Windows/System32/include/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/inttypes.h
c:/ghs/comp_202214/ansi/Windows/include/inttypes.h
c:/ghs/comp_202214/ansi/Windows/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/wbem/include/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/wbem/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/WindowsPowerShell/v1.0/include/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/WindowsPowerShell/v1.0/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/OpenSSH/include/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/OpenSSH/inttypes.h
c:/ghs/comp_202214/ansi/Program Files (x86)/Sennheiser/SenncomSDK/include/inttypes.h
c:/ghs/comp_202214/ansi/Program Files (x86)/Sennheiser/SenncomSDK/inttypes.h
c:/ghs/comp_202214/ansi/Program Files/PuTTY/include/inttypes.h
c:/ghs/comp_202214/ansi/Program Files/PuTTY/inttypes.h
c:/ghs/comp_202214/ansi/ghs/comp_202214/include/inttypes.h
c:/ghs/comp_202214/ansi/ghs/comp_202214/inttypes.h
c:/ghs/comp_202214/ansi/ghs/cmake-3.24.0-windows-x86_64/cmake-3.24.0-windows-x86_64/include/inttypes.h
c:/ghs/comp_202214/ansi/ghs/cmake-3.24.0-windows-x86_64/cmake-3.24.0-windows-x86_64/inttypes.h
c:/ghs/comp_202214/ansi/Users/tianfang/AppData/Local/Microsoft/WindowsApps/include/inttypes.h
c:/ghs/comp_202214/ansi/Users/tianfang/AppData/Local/Microsoft/WindowsApps/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/inttypes.h
c:/ghs/comp_202214/ansi/Windows/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/wbem/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/WindowsPowerShell/v1.0/inttypes.h
c:/ghs/comp_202214/ansi/Windows/System32/OpenSSH/inttypes.h
c:/ghs/comp_202214/ansi/Program Files (x86)/Sennheiser/SenncomSDK/inttypes.h
c:/ghs/comp_202214/ansi/Program Files/PuTTY/inttypes.h
c:/ghs/comp_202214/ansi/ghs/comp_202214/inttypes.h
c:/ghs/comp_202214/ansi/ghs/cmake-3.24.0-windows-x86_64/cmake-3.24.0-windows-x86_64/bin/inttypes.h
c:/ghs/comp_202214/ansi/Users/tianfang/AppData/Local/Microsoft/WindowsApps/inttypes.h
c:/ghs/comp_202214/Windows/System32/include/inttypes.h
c:/ghs/comp_202214/Windows/System32/inttypes.h
c:/ghs/comp_202214/Windows/include/inttypes.h
c:/ghs/comp_202214/Windows/inttypes.h
c:/ghs/comp_202214/Windows/System32/wbem/include/inttypes.h
c:/ghs/comp_202214/Windows/System32/wbem/inttypes.h
c:/ghs/comp_202214/Windows/System32/WindowsPowerShell/v1.0/include/inttypes.h
c:/ghs/comp_202214/Windows/System32/WindowsPowerShell/v1.0/inttypes.h
c:/ghs/comp_202214/Windows/System32/OpenSSH/include/inttypes.h
c:/ghs/comp_202214/Windows/System32/OpenSSH/inttypes.h
c:/ghs/comp_202214/Program Files (x86)/Sennheiser/SenncomSDK/include/inttypes.h
c:/ghs/comp_202214/Program Files (x86)/Sennheiser/SenncomSDK/inttypes.h
c:/ghs/comp_202214/Program Files/PuTTY/include/inttypes.h
c:/ghs/comp_202214/Program Files/PuTTY/inttypes.h
C:/ghs/comp_202214/include/inttypes.h
c:/ghs/comp_202214/ghs/comp_202214/inttypes.h
c:/ghs/comp_202214/ghs/cmake-3.24.0-windows-x86_64/cmake-3.24.0-windows-x86_64/include/inttypes.h
c:/ghs/comp_202214/ghs/cmake-3.24.0-windows-x86_64/cmake-3.24.0-windows-x86_64/inttypes.h
c:/ghs/comp_202214/Users/tianfang/AppData/Local/Microsoft/WindowsApps/include/inttypes.h
c:/ghs/comp_202214/Users/tianfang/AppData/Local/Microsoft/WindowsApps/inttypes.h
c:/ghs/comp_202214/Windows/System32/inttypes.h
c:/ghs/comp_202214/Windows/inttypes.h
c:/ghs/comp_202214/Windows/System32/wbem/inttypes.h
c:/ghs/comp_202214/Windows/System32/WindowsPowerShell/v1.0/inttypes.h
c:/ghs/comp_202214/Windows/System32/OpenSSH/inttypes.h
c:/ghs/comp_202214/Program Files (x86)/Sennheiser/SenncomSDK/inttypes.h
c:/ghs/comp_202214/Program Files/PuTTY/inttypes.h
c:/ghs/comp_202214/ghs/comp_202214/inttypes.h
c:/ghs/comp_202214/ghs/cmake-3.24.0-windows-x86_64/cmake-3.24.0-windows-x86_64/bin/inttypes.h
c:/ghs/comp_202214/Users/tianfang/AppData/Local/Microsoft/WindowsApps/inttypes.h

The item was not found.

=================================
inttypes.h is not found.
And this debug only print the search path of find_file() macro, not print for check_include_file_cxx() macro, right? How to print search path for check_include_file_cxx() macro if I am corrected?

You can try adding to that list of paths. If you know where it is, that’s probably the best solution (at least with my knowledge of GHS).

You can insert macros into the top level project by using GHS_GPJ_MACROS. Something like set(GHS_GPJ_MACROS "__ARCH_NAME=arm64" "__BSP_NAME=platform-zynq-mp") should insert the macros into the top level project. This variable needs to be prior to a project() call like in a toolchain file, or on the command line, or in the same CMakeLists.txt file as the project() command.