Reputation: 131950
I've written a small CMake module for, well, it doesn't matter what for. The point is that it acts as follows:
scripts/whatever.sh
(under the project directory) is invoked.cat
's a 'here-file' containing a C program to the C compiler found by CMake (with fallback to cc
)This is relatively robust on Unix-like systems, where cat
and bash
are available and when the path separator is /
. (There may be other assumptions I'm ignoring.) But - I want this to work on Windows, and other systems as well. How do I go about doing this?
Notes:
Upvotes: 1
Views: 99
Reputation: 66061
You may use CMake scripts for being cross-platform. Many things may be performed directly in CMakeLists.txt
and scripts included from it:
"Here in document" support in CMake is not the best, but it is not very difficult to store text of a small program into a CMake variable.
execute_process
is able to run external programs from CMake script and store output of that program in CMake variable. Also, try_compile
or try_run
may be useful in some scenarios.
Upvotes: 1