I am trying to add a new C-like language which called "foo" in CMake, which needs to use a specific modifed complier
I tried from Generic rule from makefile to CMake and it seems work when compiling a single foo
file.
However I found that command include_directories
doesn't work when I use it.
Here I list the changes which I made
CMakeDetermineFOOCompiler.cmake:
find_program(CMAKE_FOO_COMPILER NAMES "clang++" PATHS "~/out/install/bin" DOC "FOO Compiler")
mark_as_advanced(CMAKE_FOO_COMPILER)
message(STATUS CMAKE_FOO_COMPILER: ${CMAKE_FOO_COMPILER})
set(CMAKE_FOO_SOURCE_FILE_EXTENSIONS foo)
set(CMAKE_FOO_COMPILER_ENV_VAR "FOO")
configure_file(${CMAKE_ROOT}/Modules/CMakeFOOCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeFOOCompiler.cmake @ONLY)
CMakeFOOInformation.cmake:
include(CMakeCommonLanguageInclude)
if(UNIX)
set(CMAKE_FOO_OUTPUT_EXTENSION .o)
else()
set(CMAKE_FOO_OUTPUT_EXTENSION .obj)
endif()
set(_INCLUDED_FILE 0)
if(NOT CMAKE_FOO_COMPILE_OBJECT)
set(CMAKE_FOO_COMPILE_OBJECT "<CMAKE_FOO_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
endif()
if(NOT CMAKE_FOO_CREATE_SHARED_LIBRARY)
set(CMAKE_FOO_CREATE_SHARED_LIBRARY
"<CMAKE_FOO_COMPILER> <CMAKE_SHARED_LIBRARY_FOO_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_FOO_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
endif()
if(NOT CMAKE_FOO_CREATE_SHARED_MODULE)
set(CMAKE_FOO_CREATE_SHARED_MODULE ${CMAKE_FOO_CREATE_SHARED_LIBRARY})
endif()
if(NOT CMAKE_FOO_LINK_EXECUTABLE)
set(CMAKE_FOO_LINK_EXECUTABLE
"<CMAKE_FOO_COMPILER> <FLAGS> <CMAKE_FOO_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endif()
set(CMAKE_FOO_INFORMATION_LOADED 1)
CMakeFOOCompiler.cmake.in:
set(CMAKE_FOO_COMPILER "@CMAKE_FOO_COMPILER@")
set(CMAKE_FOO_COMPILER_LOADED 1)
set(CMAKE_FOO_SOURCE_FILE_EXTENSIONS @CMAKE_FOO_SOURCE_FILE_EXTENSIONS@)
set(CMAKE_FOO_OUTPUT_EXTENSION @CMAKE_FOO_OUTPUT_EXTENSION@)
set(CMAKE_FOO_COMPILER_ENV_VAR "@CMAKE_FOO_COMPILER_ENV_VAR@")
CMakeTestFOOCompiler.cmake:
set(CMAKE_FOO_COMPILER_WORKS 1 CACHE INTERNAL "")
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.0.0)
project(FOO_demo)
enable_language(FOO)
set(FOO_home /home/FOO_20210731/operations)
include_directories(${FOO_home}/include)
add_executable(test_foo test.foo)
When I use command make
, I got a warning:
/home/FOO_20210731/operations/include: 'linker' input unused [-Wunused-command-line-argument]
and then it comes a fatal error, shows that included head files not found:
/home/FOO_20210731/operations/include/FOO_header/foo_rt.h:3:10: fatal error: 'FOO_header/foo_rt.h' file not found
#include "FOO_header/foo_rt.h"
It seems that include_directories
didn't work, and I guess that some changes need to be added on those .cmake
files.
How to make include_directories
working for my case?