How to add cmake options on Windows?

62 views Asked by At

I need to build a library for Linux and Windows with options FIRST_OPTION=1 and SECOND_OPTION=1.

For Linux I just use:

make FIRST_OPTION=1 SECOND_OPTION=1

And everything works OK

For Windows I use cmake and Visual Studio:

cmake -G "Visual Studio 17 2022" -A Win32 -S D:\lib60870-2.3.1\lib60870-C -B "build32"
cmake --build build32 --config Release

But where to put options in this command on cmake?

2

There are 2 answers

0
Nika_Rika On BEST ANSWER

it turned out:

cmake -SECOND_OPTION=1 -FIRST_OPTION=1 -G "Visual Studio 17 2022" -A Win32 -B "build32"
2
Burak On

Add variables at configure time with -D flag.

cmake -D SECOND_OPTION=1 -D FIRST_OPTION=1 -G "Visual Studio 17 2022" -A Win32 -S D:\lib60870-2.3.1\lib60870-C -B "build32"
cmake --build build32 --config Release