CMake automatically recognizes new file extensions

When I add source files to the target, they are automatically recognized if they are associated with C / C ++ file extensions. What I want to do is that if I put the sources xxx.foo, all .foo files are processed using a predefined set of compiler commands.

I know the way is using add_custom_command, but all the examples I've seen use fixed file names, such as used here http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F

Any ideas on the right approach to the problem?

+3
source share
2 answers

- CMake add_executable add_library - , .foo add_executable add_library. :.

set (FOO_SRCS "main.cpp" "module.cpp" "xxx.foo" "yyy.foo")
foo_add_executable(fooexec ${FOO_SRCS})
foo_add_library(foolib ${FOO_SRCS})

CMC FindCUDA . CUDA_ADD_EXECUTABLE CUDA_ADD_LIBRARY, .cu NVIDIA C.

+2

? .

file( GLOB MY_FOO_FILES *.foo )
add_library( foolib "main.cpp" ${MY_FOO_FILES} )

.

-1

Source: https://habr.com/ru/post/1785014/


All Articles