[CMake] code::blocks project generated by cmake can not set arguments to main func

tfjiang jtf198711 at gmail.com
Wed Dec 22 02:33:16 EST 2010


Hi,everyone.
While using cmake to generate a code::blocks project, I met a problem. I
can not send argument to "int main(int argc,char *argv[])". I found some
suggestions like that: add arguments in "projects-send programs'
argument". It works in my testing  project which is directly generated
by code::blocks, but if the project is generated by cmake, there is an
error "You can not run a commands-only target".
Also, I notice that the cmake project doesn't contain Debug/Releas
directories.

my test.cpp:
*********************************
#include <iostream>
int main(int argc,char* argv[])
{
std::cout << "argc:" << argc << std::endl;
std::cout << "argv:" << argv[1] << std::endl;
	return 0;
}
************************************

my CMakeLists.txt
************************************
cmake_minimum_required(VERSION 2.8)
add_executable(hello hello.cpp)
*************************************

Hope someone can do me a favor,any suggestion will be appreciated.




More information about the CMake mailing list