From what I can glean online, I’ve tried this:

set_source_files_properties(foo.bar  PROPERTIES  LANGUAGE  CXX)
add_executable(foo  foo.bar)
set_target_properties(foo  PROPERTIES  LINKER_LANGUAGE  CXX)

but it doesn’t work.
What am I missing?

0 Mon 20:16:15 yost
1181 Z% cat CMakeLists.txt    
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(asm CXX)

set_source_files_properties(foo.bar PROPERTIES LANGUAGE CXX)
add_executable(foo foo.bar)
set_target_properties(foo PROPERTIES LINKER_LANGUAGE CXX)
0 Mon 20:16:43 yost
1182 Z% cat foo.bar 
#include <iostream>

int main(int argc, char* argv[]) {
  std::cout << "Hello\"\n";
  return 0;
}
0 Mon 20:16:46 yost
1183 Z% cd build ; cmake ..       
-- The CXX compiler identification is GNU 4.9.2
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /opt/local/bin/c++
-- Check for working CXX compiler: /opt/local/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yost/p/c++/cmake/asm/build
0 Mon 20:16:58 yost
1184 Z% make
Scanning dependencies of target foo
[100%] Building CXX object CMakeFiles/foo.dir/foo.bar.o
c++: warning: /Users/yost/p/c++/cmake/asm/foo.bar: linker input file unused 
because linking not done
Linking CXX executable foo
c++: error: CMakeFiles/foo.dir/foo.bar.o: No such file or directory
CMakeFiles/foo.dir/build.make:85: recipe for target 'foo' failed
make[2]: *** [foo] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/foo.dir/all' failed
make[1]: *** [CMakeFiles/foo.dir/all] Error 2
Makefile:75: recipe for target 'all' failed
make: *** [all] Error 2
2 Mon 20:17:01 yost
1185 Z% rm -rf * ; cmake ..
zsh: sure you want to delete all the files in /Users/yost/p/c++/cmake/asm/build 
[yn]? y
-- The CXX compiler identification is GNU 4.9.2
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /opt/local/bin/c++
-- Check for working CXX compiler: /opt/local/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/yost/p/c++/cmake/asm/build
0 Mon 20:23:00 yost
1201 Z% make VERBOSE=1
/Applications/CMake.app/Contents/bin/cmake -H/Users/yost/p/c++/cmake/asm 
-B/Users/yost/p/c++/cmake/asm/build --check-build-system 
CMakeFiles/Makefile.cmake 0
/Applications/CMake.app/Contents/bin/cmake -E cmake_progress_start 
/Users/yost/p/c++/cmake/asm/build/CMakeFiles 
/Users/yost/p/c++/cmake/asm/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/Users/yost/p/c++/cmake/asm/build'
make -f CMakeFiles/foo.dir/build.make CMakeFiles/foo.dir/depend
make[2]: Entering directory '/Users/yost/p/c++/cmake/asm/build'
cd /Users/yost/p/c++/cmake/asm/build && 
/Applications/CMake.app/Contents/bin/cmake -E cmake_depends "Unix Makefiles" 
/Users/yost/p/c++/cmake/asm /Users/yost/p/c++/cmake/asm 
/Users/yost/p/c++/cmake/asm/build /Users/yost/p/c++/cmake/asm/build 
/Users/yost/p/c++/cmake/asm/build/CMakeFiles/foo.dir/DependInfo.cmake --color=
Dependee 
"/Users/yost/p/c++/cmake/asm/build/CMakeFiles/foo.dir/DependInfo.cmake" is 
newer than depender 
"/Users/yost/p/c++/cmake/asm/build/CMakeFiles/foo.dir/depend.internal".
Dependee 
"/Users/yost/p/c++/cmake/asm/build/CMakeFiles/CMakeDirectoryInformation.cmake" 
is newer than depender 
"/Users/yost/p/c++/cmake/asm/build/CMakeFiles/foo.dir/depend.internal".
Scanning dependencies of target foo
make[2]: Leaving directory '/Users/yost/p/c++/cmake/asm/build'
make -f CMakeFiles/foo.dir/build.make CMakeFiles/foo.dir/build
make[2]: Entering directory '/Users/yost/p/c++/cmake/asm/build'
/Applications/CMake.app/Contents/bin/cmake -E cmake_progress_report 
/Users/yost/p/c++/cmake/asm/build/CMakeFiles 1
[100%] Building CXX object CMakeFiles/foo.dir/foo.bar.o
/opt/local/bin/c++     -o CMakeFiles/foo.dir/foo.bar.o -c 
/Users/yost/p/c++/cmake/asm/foo.bar
c++: warning: /Users/yost/p/c++/cmake/asm/foo.bar: linker input file unused 
because linking not done
Linking CXX executable foo
/Applications/CMake.app/Contents/bin/cmake -E cmake_link_script 
CMakeFiles/foo.dir/link.txt --verbose=1
/opt/local/bin/c++    -Wl,-search_paths_first -Wl,-headerpad_max_install_names  
CMakeFiles/foo.dir/foo.bar.o  -o foo  
c++: error: CMakeFiles/foo.dir/foo.bar.o: No such file or directory
CMakeFiles/foo.dir/build.make:85: recipe for target 'foo' failed
make[2]: *** [foo] Error 1
make[2]: Leaving directory '/Users/yost/p/c++/cmake/asm/build'
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/foo.dir/all' failed
make[1]: *** [CMakeFiles/foo.dir/all] Error 2
make[1]: Leaving directory '/Users/yost/p/c++/cmake/asm/build'
Makefile:75: recipe for target 'all' failed
make: *** [all] Error 2
2 Mon 20:23:04 yost
1202 Z% 

(I added the light blue and orange coloring by hand for readability.)

-- 

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