Using Sublime Text with cmake (build system)

I am using Sublime Text in Ubuntu and learning OpenCV. Until today, I was using Sublime Text to write and save the code, and using Terminal for compiling.

I am compiling with the following code:

cmake .
make
./a.out

But for fast processing, I am trying to make my build system and I want to make this all automatically by pressing Ctrl + B

I've tried the following code in a custom build system but it fails:

{
    "cmd": ["cmake ."],
    "cmd": ["make"],
    "cmd": ["./a.o"],
    "selector": "source.c++",
    "shell": true,

    "windows":
    {
        "cmd": ["cl", "/Fo${file_path}", "/O2", "$file"],
        "selector": "source.c++",
        "shell": true
    }
}

Any ideas? Thanks.

Answers


You should only have one "cmd" key in your build system. Please read the docs for more information. Instead, you can concatenate your commands using the && operator:

{
    "cmd": ["cmake .", "&&", "make", "&&", "./a.out"],
    "selector": "source.c++",
    "shell": true,
}

Since you're on Linux, you don't need the Windows stuff at all.


You can use cmake to create a sublime project. Just execute

cmake -G "Sublime Text 2 - Unix Makefiles" .

I don't know if it works for subime text 3 since I don't have it installed


Thanks to MattDMo, I have built a build system that works properly, here it is:

{
    "cmd": ["cp /home/as/Documents/c++/opencv/CMakeLists.txt ${file_path} &&  cmake . && make && ./project"], "working_dir": "${file_path}",
    "selector": "source.c++",
    "shell": true
}

It copies the CMakeLists.txt (Which is a default CMakeList.txt I have prepared to be suitable with every project) to the current project directory and runs the project.

Additionally, CMakeLists.txt includes the following text:

cmake_minimum_required(VERSION 2.8)
project( project )
find_package( OpenCV REQUIRED )
add_executable( project main.cpp )
target_link_libraries( project ${OpenCV_LIBS} )

I hope that will run all of OpenCV projects!


Need Your Help

Send More command (Val) to Arduino?

vb.net arduino led controlling

My project is controlling LED light by using Visual basic Program made by me.

Data model for a extensible web form

database-design forms

Suppose that I have a form that contains three 10 fields: field1..field10. I store the form data in one or more database tables, probably using 10 database columns.