HowTo: TFS --> check out C/C++ source files --&

2019-09-21 01:08发布

问题:

The title explains my purpose and speaks out different problems i encountered trying to implement it:

  1. Check out a TFS-Project with the Android Studio TFVC-Plugin was not very difficult - but i am not able to import the native code project as a module in my Android application. I tried to include it through settings.gradle and by new module without success.
  2. I built the native (C) libraries using cmakelists.txt linking to the path i checked out. But it seems the dependencies are not set up 100% correct. I can include all files fine (for the compiler) but when i build i get the following error message: "'File_a.h' not found". Directory:

    AndroidStudioProjects
                |
                + My_Android_Application
                |
                + TFVC_Workspace
                           |
                            + Lib_a
                           |        |
                           |        - File_a.h
                           |        - File_b.h
                           |        - File_b.c
                           |
                            + Lib_b depending on Lib_a
                                    |
                                    - File_c.h
                                    - File_c.c
                                    - File_d.h
                                    - File_d.c
  3. I tried to use different CMakeLists.txt according to this guide, but since my TFS files are not stored in subdirectories to the CMakeLists in my Android Studio i got stuck.

I am not able to bring all the bricks together and i think theres (JUST a BIT) confusion in my hung up brain - therefore your help to figure out errors, wrong approaches, broken design, etc. is highly appreciated!

P.S. sorry so much for the bad Directory Tree - was not able to make it better. If you need more informations about files/structure please let me know!

CMakeLists.txt (located in C:/Users//AndroidStudioProjects/Android_Project/app)

cmake_minimum_required(VERSION 3.4.1)
set(TFC_Path C:/Users/<user>/AndroidStudioProjects/TFVC/)
add_library( TFC_Lib_a 
             SHARED   
             ${TFC_Path}/Lib_a/File_a.h
             ${TFC_Path}/Lib_a/File_b.c                                   
             )
target_include_directories( TFC_Lib_a PUBLIC ${TFC_Path}/Interface_headers)


add_library( TFC_Lib_b 
             SHARED   
             ${TFC_Path}/Lib_b/File_c.c
             ${TFC_Path}/Lib_b/File_d.c                                   
             )

#since not all headers are automatically included, though File_a.h was listed in add_library(Lib_a), but Lib_b needs that header i am adding following line:
target_include_directories( TFC_Lib_a PUBLIC ${TFC_Path}/Lib_a) 

target_link_libraries( applications_jni TFC_Lib_b)
target_link_libraries( TFC_Lib_b TFC_Lib_a)

Update If i dont include File_a.h in Lib_a the compiler is not complaining, since the header is found through target_include_directories, but when i build the error of missing Lib_a.h remains!

回答1:

Well i solved the include problem by adding a "../Lib_a/" before the "File_a.h" include statement. Since there are lots of files in the libraries to adjust and they are from a TFS, so this is not really the answer i was looking for. I thought that after specifying the library dependencies in CMakeLists you could simply include the file. Now: How to set up CMakeLists to not have to change the include statements from a TFS project?!