How can ecl include asdf dependencies in an executable? (take 2) - lisp

This question was asked and answered by ayrnieu at
How can ECL include ASDF dependencies in an executable?
But the example code he linked to does not actually involve any dependencies. I've tried copying the model in the stumpwm code he refers to but I can't get it to work. He are my files.
---- ecl-test.asd ----
(defsystem "ecl-test"
:description "test of asdf:make-build"
:depends-on (:mydefs)
:components ((:file "package")
(:file "ecl-test" :depends-on ("package"))
(:file "main" :depends-on ("package" "ecl-test"))
)
)
---- ecl-test.lisp ----
(in-package :ecl-test)
(defun test ()
(format t "testing...~%")
;; Note that with the next line commented out,
;; the program never uses the package "mydefs".
;; (format t (write-to-string (mydefs:number-sequence :from 2 :to 7)))
(format t "...done~%"))
---- package.lisp ----
(defpackage :ecl-test
(:use :cl
:mydefs
)
(:export :test))
---- main.lisp ----
(ecl-test:test)
(ext:quit)
This compiles successfully (in slime):
CL-USER> (asdf:make-build 'ecl-test :type :program :monolithic t :epilogue-code '(ext:quit 0))
; loading system definition from /home/dabrowsa/lisp/ecl-test/ecl-test.asd into
; #<ASDF0 package>
;;; Loading "/home/dabrowsa/lisp/ecl-test/ecl-test.asd"
;;; Compiling /home/dabrowsa/lisp/ecl-test/package.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; End of Pass 1.
;;; Note: Creating tag: "_eclitxZgyvjVscp1_KzxnJ9z" for #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/package.c" -o "/home/dabrowsa/lisp/ecl-test/package.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/package.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Found tag: "_eclitxZgyvjVscp1_KzxnJ9z" for /home/dabrowsa/lisp/ecl-test/package.o
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITMs8gOO.c" -o "/tmp/ECLINITMs8gOO.o"
;;; Note: Invoking external command:
;;; gcc -o "/home/dabrowsa/lisp/ecl-test/package.fas" -L"/usr/lib/" "/tmp/ECLINITMs8gOO.o" "/home/dabrowsa/lisp/ecl-test/package.o" -shared -lecl -lgmp -lgc -ldl -lm
;;; Loading "/home/dabrowsa/lisp/ecl-test/package.fas"
;;; Compiling /home/dabrowsa/lisp/ecl-test/ecl-test.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; Compiling (DEFUN TEST ...).
;;; End of Pass 1.
;;; Note: Creating tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Emitting code for TEST.
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/ecl-test.c" -o "/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/ecl-test.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Note: Found tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for /home/dabrowsa/lisp/ecl-test/ecl-test.o
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITg28qfo.c" -o "/tmp/ECLINITg28qfo.o"
;;; Note: Invoking external command:
;;; gcc -o "/home/dabrowsa/lisp/ecl-test/ecl-test.fas" -L"/usr/lib/" "/tmp/ECLINITg28qfo.o" "/home/dabrowsa/lisp/ecl-test/ecl-test.o" -shared -lecl -lgmp -lgc -ldl -lm
;;; Loading "/home/dabrowsa/lisp/ecl-test/ecl-test.fas"
;;; Compiling /home/dabrowsa/lisp/ecl-test/main.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;; End of Pass 1.
;;; Note: Creating tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/home/dabrowsa/lisp/ecl-test/main.c" -o "/home/dabrowsa/lisp/ecl-test/main.o"
;;; Finished compiling /home/dabrowsa/lisp/ecl-test/main.lisp.
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Found tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITeop9MY.c" -o "/tmp/ECLINITeop9MY.o"
;;; Note: Invoking external command:
;;; gcc -o "/home/dabrowsa/lisp/ecl-test/main.fas" -L"/usr/lib/" "/tmp/ECLINITeop9MY.o" "/home/dabrowsa/lisp/ecl-test/main.o" -shared -lecl -lgmp -lgc -ldl -lm
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/main.o"
;;; Note: Found tag: "_eclJi0DFzaXyAEw1_4LynJ9z" for /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/ecl-test.o"
;;; Note: Found tag: "_eclclGsJgWGIqMw1_y1ynJ9z" for /home/dabrowsa/lisp/ecl-test/ecl-test.o
;;; Note: Scanning #P"/home/dabrowsa/lisp/ecl-test/package.o"
;;; Note: Found tag: "_eclitxZgyvjVscp1_KzxnJ9z" for /home/dabrowsa/lisp/ecl-test/package.o
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITsLgWth.c" -o "/tmp/ECLINITsLgWth.o"
;;; Note: Invoking external command:
;;; ar cr /home/dabrowsa/lisp/ecl-test/libecl-test.a /tmp/ECLINITsLgWth.o /home/dabrowsa/lisp/ecl-test/package.o /home/dabrowsa/lisp/ecl-test/ecl-test.o /home/dabrowsa/lisp/ecl-test/main.o
;;; Note: Invoking external command:
;;; ranlib /home/dabrowsa/lisp/ecl-test/libecl-test.a
;;; Note: Invoking external command:
;;; gcc "-I/usr/include/" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC -Dlinux -O -w -c "/tmp/ECLINITTF1dqA.c" -o "/tmp/ECLINITTF1dqA.o"
;;; Note: Invoking external command:
;;; gcc -o "/home/dabrowsa/lisp/ecl-test/ecl-test-mono" -L"/usr/lib/" "/tmp/ECLINITTF1dqA.o" "/home/dabrowsa/lisp/ecl-test/libecl-test.a" -lecl -lgmp -lgc -ldl -lm #<ASDF::PROGRAM-OP NIL 38147728>
But executing ecl-test-mono produces an error.
~/lisp/ecl-test$ ./ecl-test-mono
The function ASDF::SYSTEM-REGISTERED-P is undefined.
No restarts available.
Broken at NIL.
ECL-TEST>>
SYSTEM-REGISTERED-P seems to be an unexported function in ASDF, I have no idea why that's popping up here, but then, I'm a newbie so what do I know.

You're better off asking this on ecls-list.
Or try this in your call to MAKE-BUILD:
:prologue-code '(require :asdf)

Related

Installing B::C with cpanm hangs?

When I install B::C with cpanm, it hangs
$ sudo cpanm B::C
--> Working on B::C
Fetching http://www.cpan.org/authors/id/R/RU/RURBAN/B-C-1.57.tar.gz ... OK
Configuring B-C-1.57 ... OK
Building and testing B-C-1.57 ... ^C
First you'll want to try to check the install by using the verbose flag cpanm -v B::C, after which you should see a lot of looping like
x86_64-linux-gnu-gcc -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/x86_64-linux-gnu/perl/5.28/CORE -o cccode1_o1 cccode1_o1.c -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.28/CORE -lperl -ldl -lm -lpthread -lc -lcrypt 2>/dev/null 2>&1
# /usr/bin/ld: cannot find -lperl
collect2: error: ld returned 1 exit status
This is because ld can't find libperl.so. If you're on Debian you'll need to run,
sudo apt install libperl-dev

How to recompile libperl.a object files with -fPIC flag?

This question arose when trying to fix some installation problems
with QtCore4. At some point make tried to run the following command:
/usr/bin/c++ -fPIC -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong \
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O3 -DNDEBUG \
-shared -Wl,-soname,QtCore4.so -o ../../blib/arch/auto/QtCore4/QtCore4.so \
CMakeFiles/perlqtcore4.dir/binding.cpp.o \
CMakeFiles/perlqtcore4.dir/handlers.cpp.o \
CMakeFiles/perlqtcore4.dir/marshall_types.cpp.o \
CMakeFiles/perlqtcore4.dir/util.cpp.o \
CMakeFiles/perlqtcore4.dir/QtCore4.c.o \
-lQtCore -lQtGui -lQtNetwork \
/home/hakon/perlbrew/perls/perl-5.24.1/lib/5.24.1/x86_64-linux/CORE/libperl.a \
../../smokeqt/qtgui/libsmokeqtgui.so.3.0.0 \
../../smokeqt/qtnetwork/libsmokeqtnetwork.so.3.0.0 \
-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc -lQtGui -lQtNetwork \
../../smokeqt/qtcore/libsmokeqtcore.so.3.0.0 -lQtCore \
../../smokegen/bin/libsmokebase.so.3.0.0 \
-Wl,-rpath,/home/hakon/Qt4-0.99.0/smokeqt/qtgui:/home/hakon/Qt4-0.99.0/smokeqt/qtnetwork:/home/hakon/Qt4-0.99.0/smokeqt/qtcore:/home/hakon/Qt4-0.99.0/smokegen/bin:
which failed with the following error message from the linker:
/usr/bin/ld: /home/hakon/perlbrew/perls/perl-5.24.1/lib/5.24.1/x86_64-linux/CORE/libperl.a(toke.o):
relocation R_X86_64_PC32 against symbol `PL_curcop' can not be used when making
a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
From the error message, it seems to me that the object files (here: toke.o) in
libperl.a was compiled without the -fPIC flag set.
The questions I have now are:
How can I recompile the object files in libperl.a with -fPIC ?
Could this recompilation cause other problems not related to
QtCore4 (since it is likely that libperl.a will be used (linked
with) by other applications/programs not related to QtCore4)?
I am using Ubuntu 16.10 and perl version 5.24.1.
How can I recompile the object files in libperl.a with -fPIC
By recompiling libperl.a with the -fPIC flag.
./Configure -des -Accflags=-fPIC ...
Could this recompilation cause other problems not related to QtCore4 (since it is likely that libperl.a will be used (linked with) by other applications/programs not related to QtCore4)?
Yes. Prefer a shared libperl. -Duseshrplib
Which is required when embedding perl into shared libs. You can do away with the -fPIC trick which is required on ELF, but a shared libperl makes it much easier.

Dmake file error with Math::TrulyRandom module

I listened to this one person's advice when I tried installing Math::TrulyRandom (A random number generator vs pseudorandom), I was running 'dmake' and he told me to ask about the errors on a different question.
My first question is here.
Here is what went wrong in the terminal:
C:\Users\Jlinne\Documents> cpanm --prompt Math::TrulyRandom
--> Working on Math::TrulyRandom
Fetching http://www.cpan.org/authors/id/G/GA/GARY/Math-TrulyRandom-1.0.tar.gz ... OK
Configuring Math-TrulyRandom-1.0 ... OK
Building and testing Math-TrulyRandom-1.0 ... Building Math-TrulyRandom-1.0 failed.
You can s)kip, r)etry, e)xamine build log, or l)ook ? [s] l
Entering C:/Users/Jlinne/.cpanm/work/1476593741.7660/Math-TrulyRandom-1.0 with C:\WINDOWS\system32\cmd.exe
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\Users\Jlinne\.cpanm\work\1476593741.7660\Math-TrulyRandom-1.0>perl Makefile.PL
Generating a dmake-style Makefile
Writing Makefile for Math::TrulyRandom
Writing MYMETA.yml and MYMETA.json
C:\Users\Jlinne\.cpanm\work\1476593741.7660\Math-TrulyRandom-1.0>dmake
Skip blib\lib\Math\TrulyRandom.pm (unchanged)
Skip blib\lib\Math\TrulyRandom.pod (unchanged)
Running Mkbootstrap for Math::TrulyRandom ()
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "TrulyRandom.bs"
gcc -c -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing -mms-bitfields -s -O2 -DVERSION=\"1.0\" -DXS_VERSION=\"1.0\" "-IC:\STRAWB~1\perl\lib\CORE" TrulyRandom.c
gcc -c -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing -mms-bitfields -s -O2 -DVERSION=\"1.0\" -DXS_VERSION=\"1.0\" "-IC:\STRAWB~1\perl\lib\CORE" truerand.c
truerand.c: In function 'tick':
truerand.c:57:19: error: storage size of 'it' isn't known
struct itimerval it, oit;
^
truerand.c:57:23: error: storage size of 'oit' isn't known
struct itimerval it, oit;
^
truerand.c:62:16: error: 'ITIMER_REAL' undeclared (first use in this function)
if (setitimer(ITIMER_REAL, &it, &oit) < 0)
^
truerand.c:62:16: note: each undeclared identifier is reported only once for each function it appears in
truerand.c: In function 'interrupt':
truerand.c:71:16: error: 'SIGALRM' undeclared (first use in this function)
(void) signal(SIGALRM, interrupt);
^
truerand.c: In function 'roulette':
truerand.c:86:16: error: 'SIGALRM' undeclared (first use in this function)
(void) signal(SIGALRM, interrupt);
^
dmake: Error code 129, while making 'truerand.o'
C:\Users\Jlinne\.cpanm\work\1476593741.7660\Math-TrulyRandom-1.0>
Math::TrulyRandom is broken, and should not (indeed, cannot) be used.
It was written in 1996, and only works correctly on certain UNIX systems which existed at the time (like SunOS 4). It fails to generate random data on modern Linux systems, and cannot be compiled at all on Windows.
If you need a random number generator and rand won't cut it, look for another module. Math::Random::Secure or Crypt::Random, for instance.

Matlab Mex compilation error

I’m using the Random Forest library for Matlab (link). I’m using it for classification. On Windows it works very well out of the box (precombiled mex files) but I also want to run it on a CentOS cluster.
I have tried to compile it on the cluster by executing make mex but I’m getting an error. The output is as follows:
rm twonorm_test -rf
rm tempbuild/*.o *.o -rf
rm *~ -rf
rm *.mexw32 twonorm_test -rf
rm *.mexa64 -rf
rm classRF -rf
rm *.exe -rf
echo 'Compiling classTree.cpp'
Compiling classTree.cpp
g++ -fpic -O2 -funroll-loops -msse3 -c src/classTree.cpp -o tempbuild/classTree.o
echo 'Compiling Cokus (random number generator)'
Compiling Cokus (random number generator)
g++ -fpic -O2 -funroll-loops -msse3 -c src/cokus.cpp -o tempbuild/cokus.o
echo 'Compiling rfsub.f (fortran subroutines)'
Compiling rfsub.f (fortran subroutines)
gfortran -O2 -fpic -c src/rfsub.f -o rfsub.o
echo 'Compiling rfutils.cpp'
Compiling rfutils.cpp
g++ -fpic -O2 -funroll-loops -msse3 -c src/rfutils.cpp -o tempbuild/rfutils.o
echo 'Generating Mex'
Generating Mex
mex src/mex_ClassificationRF_train.cpp src/classRF.cpp tempbuild/classTree.o tempbuild/rfutils.o rfsub.o tempbuild/cokus.o -o mexClassRF_train -lgfortran -lm -DMATLAB -g
Unknown MEX argument '-o'.
make: *** [mex_classRF] Error 255
Does somebody knows how to solve this issue? If you want, you can take RF_MexStandalone-v0.02.zip from the above link and then go to randomforest-matlab/RF_Reg_C/Makefile.
Edit: I have change -o to -output but now the output is the following:
rm twonorm_test -rf
rm tempbuild/*.o *.o -rf
rm *~ -rf
rm *.mexw32 twonorm_test -rf
rm *.mexa64 -rf
rm classRF -rf
rm *.exe -rf
echo 'Compiling classTree.cpp'
Compiling classTree.cpp
g++ -fpic -O2 -funroll-loops -msse3 -c src/classTree.cpp -o tempbuild/classTree.o
echo 'Compiling Cokus (random number generator)'
Compiling Cokus (random number generator)
g++ -fpic -O2 -funroll-loops -msse3 -c src/cokus.cpp -o tempbuild/cokus.o
echo 'Compiling rfsub.f (fortran subroutines)'
Compiling rfsub.f (fortran subroutines)
gfortran -O2 -fpic -c src/rfsub.f -o rfsub.o
echo 'Compiling rfutils.cpp'
Compiling rfutils.cpp
g++ -fpic -O2 -funroll-loops -msse3 -c src/rfutils.cpp -o tempbuild/rfutils.o
echo 'Generating Mex'
Generating Mex
mex src/mex_ClassificationRF_train.cpp src/classRF.cpp tempbuild/classTree.o tempbuild/rfutils.o rfsub.o tempbuild/cokus.o -output mexClassRF_train -lgfortran -lm -DMATLAB -g
Building with 'g++'.
cc1plus: error: unrecognized command line option "-std=c++11"
make: *** [mex_classRF] Error 255
I did not find an option -std=c++11 in the makefile.
The error is quite self-explanatory: the option -o is not recognized. If you type mex -help you see the options mex accepts. Try to replace -o with -output.
EDIT regarding the std=c++11 option, you are probably using an old version of gcc compiler. You can either change it to std=c++0x which is the equivalent option (but note that some features of the c++11 standard may not be present\implemented), or upgrade to an up-to-date version of gcc.
If you need more help, please report the output of g++ --version.

CMAKE separate Linker and Compiler Flags

Right now my toolchain.cmake looks loke this:
CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
CMAKE_FORCE_CXX_COMPILER(arm-none-eabi-gcc GNU)
SET(CMAKE_ASM_COMPILER arm-none-eabi-as)
SET(CMAKE_OBJCOPY arm-none-eabi-objcopy CACHE INTERNAL "objcopy" FORCE)
SET(CMAKE_OBJDUMP arm-none-eabi-objdump CACHE INTERNAL "objdump" FORCE)
# Compiler Flags
SET(MCU_FLAGS "-mcpu=cortex-m3 -mthumb")
SET(CMAKE_BUILD_FLAGS "-O2 -g -mfpu=vfp -mfloat-abi=soft -Wa,-meabi=5 -ffunction-sections -fno-common -pedantic -Wall -Wextra -Wno-missing-field-initializers")
SET(CMAKE_C_FLAGS "${MCU_FLAGS} ${CMAKE_BUILD_FLAGS}" CACHE INTERNAL "c compiler flags")
SET(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS} CACHE INTERNAL "cxx compiler flags")
SET(CMAKE_ASM_FLAGS "-g -mcpu=cortex-m3 -mthumb -mfpu=vfp -mfloat-abi=soft -meabi=5 -warn" CACHE INTERNAL "asm compiler flags")
SET(CMAKE_EXE_LINKER_FLAGS "-mcpu=cortex-m3 -mthumb -Wall -Wextra -Wno-missing-field-initializers -g -nostartfiles -Wl,-T1.ld,-M=1.map,--gc-sections" CACHE INTERNAL "exe link flags")
The problem is that CMake passes to the Linker additionally the Compiler-flags! Is there any way to separate these two?
Another thing is if I use another compiler-tool-chain (Like Fujitsu Softtune) how can I tell CMake explicitly to take a Linker and not the compiler to Link objects?
Thanks
So i finally solved it. for evryone else with the same problem, i changed CMakelists as follow:
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE C CXX ASM)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${LD_FLAGS_STR} -m ${PROJECT_NAME}.map")
set(CMAKE_C_LINK_EXECUTABLE "FLNK907S.EXE -o <TARGET> <LINK_FLAGS> <OBJECTS>")
and it works fine...
where ${LD_FLAGS_STR} is just the list of my linker flags (own variable). and LNK907S.EXE is the name of Linker i 'm using (Fujitsu).
Try using SET_TARGET_PROPERTIES to set the link flags, respectively:
SET(MCU_FLAGS "-mcpu=cortex-m3 -mthumb")
SET(CMAKE_BUILD_FLAGS "-O2 -g -mfpu=vfp -mfloat-abi=soft -Wa,-meabi=5 -ffunction-sections -fno-common -pedantic -Wall -Wextra -Wno-missing-field-initializers")
SET(CMAKE_C_FLAGS "${MCU_FLAGS} ${CMAKE_BUILD_FLAGS}")
SET(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
SET(CMAKE_ASM_FLAGS "-g -mcpu=cortex-m3 -mthumb -mfpu=vfp -mfloat-abi=soft -meabi=5 -warn")
SET_TARGET_PROPERTIES(FOO PROPERTIES LINK_FLAGS "-mcpu=cortex-m3 -mthumb -Wall -Wextra -Wno-missing-field-initializers -g -nostartfiles -Wl,-T1.ld,-M=1.map,--gc-sections")
Here, I have assumed your excutable is called "FOO". Note that the link libaries are specified on a per-target basis. If you need special compiler flags for the target only, you can use COMPILE_FLAGS in SET_TARGET_PROPERTIES as well.
With newer versions of cmake, using generator expressions [1] has been my preferred approach.
target_compile_options(${TARGET_NAME}
PRIVATE
$<$<COMPILE_LANGUAGE:C>:${C_DEFS} ${C_FLAGS}>
$<$<COMPILE_LANGUAGE:ASM>:${ASM_FLAGS}>)
[1] https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html