Cannot generate vcxproj file in the gn tutorial hello_world - chromium

I run
gn gen out/mybuild --args="is_component_build=true is_debug=true enable_nacl=false remove_webcore_debug_symbols=true" --ide=vs --filters=//tools/gn
ninja -C out/mybuild hello_world
but no hellow_world.vcxproj generated.

Related

CMake: Building a object file from a source in a object library in a sub directory out of source

Consider the following mock project with these files:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(myproject)
add_subdirectory(sub)
# sub/CMakeLists.txt
add_library(myLib OBJECT bar.c)
add_executable(foo foo.c)
target_link_libraries(foo PRIVATE myLib)
# sub/foo.c
int main() {return 0;}
# sub/bar.c
void bar(){}
When building in source after cmake -G Unix\ Makefiles -B . -S . I can go to the the directory sub and execute make bar.o. How can I achieve the same results when building out of source? I've tried these commands from the project root:
cmake -G Unix\ Makefiles -B test-build -S .
cmake --build test-build --target sub/bar.o
cmake --build test-build --target bar.o
cmake --build test-build --target bar
I get these kinds of error messages gmake: *** No rule to make target 'sub/bar.o'. Stop.
I know it's possible to build the library, but in reality our library is quite large and I would like to focus on one file at the time.

CMAKE build gui application with MinGW

I want to build gui application with SDL2. I link SDL2 libraries(libSDL2.dll.a and libSDL2main.a) but I don't know how a can apply -mwindows flag to my application. Without him .exe file of my application doesn't show window (executing have not any effect). I use MinGW-w64 my OS is Windows 10. In command line I can do this like here (see section B). How I can apply this flag with usage cmake? Console application works fine.
I try next variant but it doesn't work.
cmake -G "MinGW Makefiles" -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D CMAKE_EXE_LINKER_FLAGS="-mwindows"
cmake -G "MinGW Makefiles" -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D CMAKE_CXX_FLAGS="-mwindows"
Also in CMakeLists.txt I try do like this
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows")
You can pass WIN32 argument to add_executable and CMake will do this for you:
add_executable(target_name WIN32 ${sources})
I basically copy-pasted the stuff, which CLion executes in the command line, and it worked:
$ cmake DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" ../
$ cmake --build ./ --target target_name -j 6
[ 50%] Building CXX object CMakeFiles/target_name.dir/main.cpp.obj
[100%] Linking CXX executable target_name.exe
[100%] Built target tree_traverse
After this the executable target_name.exe appeared in the directory.

How do I enable SSE2 from the command line

I'm compiling Dlib's Python Examples.
The compile script is:
mkdir build
cd build
cmake ../../tools/python
cmake --build . --config Release --target install
cd ..
How do I enable SSE2 from the command line? I tried adding the argument -USE_SSE2_INSTRUCTIONS=ON but got unknown argument error.
From Cmake cache file:
//Compile your program with SSE2 instructions
USE_SSE2_INSTRUCTIONS:BOOL=OFF
You forgot the -D. So you have to say, cmake -DUSE_SSE2_INSTRUCTIONS=ON

CMake putting build files in source directory

I am very new to CMake. A friend wrote a simple CMakeLists.txt for the project I am coding myself. I am using svn and have just checked out an old version on the same machine into a different folder. Now, in the original source directory (where CMakeLists.txt is located) I create the directory 'build', cd into there, and for the time being run the code
cmake -DCMAKE_BUILD_TYPE=Debug ..
This nicely puts all of the files in the build directory
-- Build files have been written to: ~/MixedFEMultigrid/build
Now when I check out to another directory, create another 'build' directory in that one and then run the CMake command I get the following
-- Build files have been written to: ~/oldCode
where oldCode is actually the parent directory. I have no idea why this is happening. Can someone explain this to me? The full CMakeLists.txt file is given below,
cmake_minimum_required (VERSION 2.6)
project (MixedFEMultigrid)
FIND_PACKAGE(LAPACK REQUIRED)
set( SRC_FILES multigrid.c
gridHandling.c
interpolation.c
linApprox.c
params.c
sparseMatrix.c
testing.c
richardsFunctions.c
definitions.c
newtonIteration.c
)
#Adds the executable with all the dependencies
add_executable (multigrid ${SRC_FILES})
#Specifies the libraries to link to the target
TARGET_LINK_LIBRARIES(multigrid ${LAPACK_LIBRARIES} m)
# Update if necessary
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic -fstrict-aliasing -std=c99 -O3")
As per the comment by escrafford I am updating to show what I do on the command line.
cd ~
mkdir oldCode
cd oldCode
svn co <repository>
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
The build files are then put into the directory 'oldCode' instead of the 'build' directory. The following, on the other hand, puts the build files into the 'build' directory
cd ~
mkdir MixedFEMultigrid
cd MixedFEMultigrid
svn co <repository>
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
That comes from a in-source cmake execution
Remember to remove cmake cache:
$ rm CMakeCache.txt
$ mkdir debug
$ cd debug
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
That has another benefit, given that cmake do not provide a clean target
$ cd ..
$ rm -rf debug
is the equivalent of make clean or more precisely make distclean

Verbose NMake Makefiles using CMake

I have been following instructions from the FAQ: Is there an option to produce more 'verbose' compiling?. I have now:
$ cat C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows.cmake
[...]
# uncomment these out to debug nmake and borland makefiles
set(CMAKE_START_TEMP_FILE "")
set(CMAKE_END_TEMP_FILE "")
set(CMAKE_VERBOSE_MAKEFILE 1)
I then regenerate my project, and run nmake:
> cmake --version
cmake version 2.8.12.2
> cmake -G"NMake Makefiles" ..\project
> nmake VERBOSE=1
[...]
[ 73%] Building CXX object apps/foobar/CMakeFiles/bla.dir/my.cpp.obj
cd C:\Dashboards\MyTests\project-build-debug-vista32-nightly\apps\foobar
C:\PROGRA~1\MICROS~1.0\VC\bin\cl.exe #C:\Users\voxxl\AppData\Local\Temp\nm1362.tmp
Is there a way to have access to the full cl command line ?
On Windows (XP or greater), Command lines are limited in length to 8,191 bytes.
Windows compiler toolsets get around this by allowing the #filepath syntax on the command line.
So VERBOSE=1 is less useful on Windows. But you can always check command line in generated *.make files
For example (path used from question):
apps/foobar/CMakeFiles/bla.dir/build.make
apps/foobar/CMakeFiles/bla.dir/flags.make