Dear All,

I am learning CMake, and one of my personal lessons is combine Java
and CMake. I made a small example (HelloWorld.java):

==========

public class HelloWorld
{
   public static void main(String[] args)
   {
      System.out.println("Hey :)");
   }
}

==========

And a CMakeLists.txt file:

==========

cmake_minimum_required(VERSION 2.8)
project(HelloWorld)

find_package(Java REQUIRED)
include(UseJava)

set(JAR_NAME HelloWorld)
set(JAVA_SOURCE_DIRECTORY )
set(JAVA_SOURCE_FILES ${JAVA_SOURCE_DIRECTORY}/HelloWorld.java)
add_jar(${JAR_NAME} ${JAVA_SOURCE_FILES})

==========

Then I go into that directory where the CMakeLists.txt is and start the command

==========
cmake --target=HelloWorld --build .
==========

Output is:

==========

-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Java: /usr/bin/java (found version "1.8.0.66")
-- Jar file /home/some/Downloads/HelloWorld/HelloWorld.jar
-- Class compiled to /home/some/Downloads/HelloWorld/CMakeFiles/HelloWorld.dir
-- Configuring done
-- Generating done
-- Build files have been written to: /home/some/Downloads/HelloWorld

==========

But when I start the command "make", then I get the following output:

==========

Scanning dependencies of target HelloWorld
make[2]: *** No rule to make target `/HelloWorld.java', needed by
`CMakeFiles/HelloWorld.dir/java_compiled_HelloWorld'.  Stop.
make[1]: *** [CMakeFiles/HelloWorld.dir/all] Error 2
make: *** [all] Error 2

==========

Can you tell me, what I am doing wrong?
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to